Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HtmlHelper NameFor method

Is there an Html.NameFor feature, that gets the name html attribute for a model item?

I'd like to use the following code in my Razor view:

<input type="text" value="@Model.User.Email" name="@Html.NameFor(x => x.User.Email)">
like image 530
stacker Avatar asked Aug 09 '10 20:08

stacker


People also ask

Which HtmlHelper object method should you use?

We can use this HTML. RadioButton() Helper method using the class to define the HTML elements. This is the loosely typed expansion method function which we can define as input type to select the (<input type="radio" >) element in razor view.

What is the purpose of HtmlHelper class?

HTML Helpers are methods that return a string. Helper class can create HTML controls programmatically. HTML Helpers are used in View to render HTML content. It is not mandatory to use HTML Helper classes for building an ASP.NET MVC application.

What is an HtmlHelper?

An HTML Helper is just a method that returns a HTML string. The string can represent any type of content that you want. For example, you can use HTML Helpers to render standard HTML tags like HTML <input>, <button> and <img> tags etc.

How many types of HTML helpers are there?

There are three types of built-in HTML helpers offered by ASP.NET.


2 Answers

Html.NameFor is now included in MVC 4.

like image 85
Mike Avatar answered Nov 15 '22 20:11

Mike


Yes, there is Html.NameFor method in the ASP.NET MVC Futures assembly.

like image 43
stacker Avatar answered Nov 15 '22 19:11

stacker