views:

393

answers:

1

I'm creating an Html TextBox via HtmlHelper and I can't get the value attribute set. I've tried both of the lines below and I have also googled but cannot find a solution:

<%= Html.TextBox("name", null, new { @class = "textbox", value = "hi" }) %>
<%= Html.TextBox("name", null, new { @class = "textbox", @value = "hi" }) %>

Both lines return an input element with value=""

What am I missing?

+3  A: 

The value is the second parameter of the Html.TextBox method :

<%= Html.TextBox("name", "hi", new { @class = "textbox" }) %>

should work

Olivier PAYEN
Wow, I'm a complete idiot. Thanks!
modernzombie