Home > DeveloperSection > Forums > How to give the id to the html textbox?
Tanuj Kumar

Total Post:134

Posted on    September-25-2013 3:12 AM


 1 Reply(s)
 1514  View(s)
Rate this:

How to give the id to the html textbox?

My html tag looks like this


Any suggestions?

ezra heywood
ezra heywood

Total Post:145

Posted on    September-25-2013 4:33 AM

By default, the TextBoxFor element will have an ID and NAME property that matches the expression property of the element.

@Html.TextBoxFor(model => model.ProductName)

In this example, the ID and NAME would be "ProductName"

If you want to specify an ID or NAME that's different from the expression property, you can use the htmlAttributes overload param.

@Html.TextBoxFor(model => model.ProductName, new { id = "myProduct", name = "myProduct" })

Modified On Apr-04-2016 11:05:30 PM

Don't want to miss updates? Please click the below button!

Follow MindStick