HOW TO GIVE THE ID TO THE HTML TEXTBOX?

Tanuj Kumar

Total Post:134

Points:940
Posted by  Tanuj Kumar
HTML5 
 1619  View(s)
Ratings:
Rate this:

How to give the id to the html textbox?

My html tag looks like this

<%=Html.TextBox("username")%>

Any suggestions?

  1. ezra heywood

    Post:145

    Points:1019
    Re: How to give the id to the html textbox?

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!