Home > DeveloperSection > Forums > How to use HTML helpers in MVC?
Anupam Mishra

Total Post:135

Points:949
Posted on    February-03-2016 10:11 PM

 ASP.Net C#  ASP.Net  ASP.NET MVC 
Ratings:


 1 Reply(s)
 206  View(s)
Rate this:
Hi Everyone,
I am working on ASP.NET MVC4 framework and i want to use HTML helpers for render HTML controls in the view.
Please can anyone give me a solution.
Thank you.


Anupam Mishra

Total Post:135

Points:949
Posted on    February-03-2016 11:19 PM

 We use use HTML helpers for render HTML controls in the view. In this example we will use HTML.TextBoxFor” is strongly typed while “HTML.TextBox” isn’t. Below is a simple HTML code which just creates a simple textbox with “StudentCode” as name.

Html.TextBox("StudentName")
Below is “Html.TextBoxFor” code which creates HTML textbox using the property name ‘StudentCode” from object “m”.

Html.TextBoxFor(m => m.StudentName)
In the same way we have for other HTML controls like for checkbox we have “Html.CheckBox” and “Html.CheckBoxFor”.   

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

Follow MindStick