MVC HTML helper class controllers
|
Go to sample .asp x source path of the page write the follows code in <div> tag
<table align= ‘center’ border=”2”>
<tr><td><%= HTML.label(“enter your name”)%></td>
<td><%=HTML.textbox(“t1”)%></td>
</tr>
<tr><td><%=HTML.label(“enter user name”)%></td>
<tr><td><%=HTML.textbox (“t2”)%></td>
</tr>
<tr><td><%=HTML.label (”enter password”)%></td>
<td><%=HTML.textbox(“t3”)%></td>
</tr>
<tr><td><%=HTML.label(“text gender”)%></td>
<td><%=HTML.radiobutton(“gender”, ”male”)%>male
<%-HTML.radiobutton(“gender”, “female”)%>female
</td>
</tr>
<tr><td><%=HTML.label(“select hobbies”)%></td>
<td><%=HTML.checkbox(“dancing”)%>dancing
<%=HTML.checkbox(“playing”)%>playing >
</td>
</tr>
<tr><td><%=HTML.label (”select qualification”)%></td>
<td><%=HTML.dropdownlist (“CB1”)%></td>
</tr>
<tr><td><%=HTML.label (”select skill set”)%></td>
<td><%=HTML.listbox(“LB1”)%></td>
</tr>
<tr>
<td><%=HTML.load (“describe your experience”)%></td>
<td><%=HTML2.textbox(“TA!1”)%></td>
</tr>
</table>
</div>
</body>
</html>
Go to home controller .cs
Write the following code —> to display the data in combo box and list box
Public action result sample ()
{
List <string> L1=new list <string> ();
L1.add (”SSC”);
L1.add (”10+2”);
L1.add (”Degree”);
List <string>L2=new list <string> ();
L2.add (”C#.net”);
L2.add (”C”);
L2.add (”ASP.net”);
View data [“CB1”] =new select list (L1);
View data [“LB1”] =new select list (L2);
Return view ();
}
Redirecting the user request using HTML helper class:
To redirect the user request from one page to other page use action link method from HTML helper class.
|
Samples
Desired to gain proficiency on ASP.Net? Explore the blog post on ASP.Net training to become a pro in ASP.Net.
Create new view page with the name samples
Go to source part and write the following code
<body>
<div>
<h1>welcome to satya technologies</h1>
<%=HTML.actionlink (“sample view”, “sample”,”home”) %>
</div>
</body>
//<%#HTML.actionlink (
“(“sample view”, “sample”,”home”) %>
Display text action name controller name
go to home controller create an action method like
Public action result sample ()
{
Return view ();
}
Go to globel. Asax file change action name
With samples and run the application
Create an action link to redirect user requires to some website
For indepth understanding click on
0 Responses on MVC HTML helper class controllers"