modernzombie
modernzombie

Reputation: 2049

Setting Value Html Attribute For Html.TextBox (MVC 1.0)

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?

Upvotes: 4

Views: 14101

Answers (1)

Olivier Payen
Olivier Payen

Reputation: 15268

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

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

should work

Upvotes: 12

Related Questions