Working with HTML helpers:
HTML helpers are used to under the HTML controls within the MVC views.
MVC will support following HTML helpers
Name Syntax
- Label
label (string text)
- Text box
textbox (string name, object value)
- Password
password (string name, object value)
- Radio button
Radiobutton (string name, object value, bool checked)
- Check box
checkbox (string name, bool checked)
- Drop down list box
Dropdown list (string nmae)
- List box
listbox (string name)
- Render action
Renderaction (string actionname, string control name)
- Link button
action link (string linktext, string action name, string controller name)
- Text area
text area (string name)
- HTML encoder
encode(string text/object value)
- Validate
validate (string model name)
- Validate message
validate message (string model name, string message)
- Form
Begin form ()
HTML.End form ()
Working with HTML helper class:
Code for dropdown list creating and list box
Go to sample view write the following code
<%= HTML.label(“select qualification”)%>
<%=HTML.DropDownList(“CB1”)%><br%>
<%=HTML.label(“select skill set”)%>
<%=HTML.listbox(“LB”)>
Go to home controller .cs
↓
Interested in ASP.net Training? Enroll now for FREE demo on ASP.net Training.
In sample action method write the following code
To add the list of elements to the combo box and list box
Public action result sample ()
{
List <string> L1=new list<string> ()}
L1.add (“USC”);
L1.add (“10+2”);
L1.add (“Degree”);
List <string> L2=new list <string> ();
L2.add (“C#.net”);
L2.add (“ASP.net”);
L2.add (“WCF”);
L2.add (“AJAX”);
View data [“cb1”] = new select list (L1);
View data [“cb2”] = new select list (L2);
Return view ();
}
For indepth understanding click on