Hi
Is it possible to have to make a html for helper in asp.net mvc 2.0 have a default value of "empty string"
Like if I do this
Html.TextBoxFor( u => u.ProductName)
would render to
<input id ="ProductName" name="ProdcutName" type="text" value="Jim" />
Now I don't want the textbox to display jim. I want it to display nothing.
<input id ="ProductName" name="ProdcutName" type="text" value="" />
I tried to do this
Html.TextBoxFor( u => u.ProductName, new { @value = " "})
but that seems to do nothing. So how can I do this. I hope you can do something like this otherwise I think these new helpers have a great flaw since now I need to use like javascript to remove them since I hardly ever want a default value in the textbox especially when I have a label right beside the textbox saying what it is.
Edit
I found that if I want to set it to a null string I have to do that in the viewmodel. What is fine but still one problem is left. In my example ProductName is a string type. But if it was say a int then it would show a default value to 0 which is something I don't want.
So you can of course set a int to a empty string. So to get it to a empty string you need to change that type to a string what kinda sucks.
Any one know away around this?
Edit 2
Also the radio button for helper does not seem to generate a "id". How do you set one?