0

i want to trim a string in asp.net mvc . i will be doing that in controller where there is a updatemodel implemented or datannotation class or a view? where will be i doing that?

tereško
  • 58,060
  • 25
  • 98
  • 150
maztt
  • 12,278
  • 21
  • 78
  • 153
  • i have a textboxes bind to the model , i want to trim any string inside the textboxes. i am using linq to sql with asp.net mvc 2 – maztt Aug 20 '10 at 10:01

1 Answers1

3

If you want trim strings that Users have entered then take a look at this answer

Although this answer only overrides the SetProperty method you could always extend the class and add a method to override the GetPropertyValue

Community
  • 1
  • 1
codingbadger
  • 42,678
  • 13
  • 95
  • 110
  • As Barry has said, take a look at that answer. I also implemented a my own ModelBinder that automatically trimmed strings. Much better. – uriDium Aug 20 '10 at 10:06