Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 628
modernzombie Avatar asked Dec 18 '22 04:12

modernzombie


1 Answers

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

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

should work

like image 120
Olivier Payen Avatar answered Dec 29 '22 11:12

Olivier Payen