Possible to have empty values with Html For Helpers such as Html.TextBoxFor()?

Posted by chobo2 on Stack Overflow See other posts from Stack Overflow or by chobo2
Published on 2010-05-16T02:57:57Z Indexed on 2010/05/16 3:00 UTC
Read the original article Hit count: 170

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2

Related posts about .NET