Wednesday, January 7, 2015

Razor View set ID to a TextBox

Set ID to a TextBox in Razor like this:
1
@Html.TextBoxFor(item => item.OperationNo, new { id = "MyId" })
Or
1
@Html.TextBoxFor(item => item.OperationNo, htmlAttributes: new { id = "MyId" })
And output will be:
1
<input ... id="MyId" name="OperationNo" type="text" />

No comments:

Post a Comment