The example in this article describes how ASP.net obtains form form values in the MVC controller. Share to everyone for your reference, specific as follows:
In the MVC controller, if we want to get directly to the value of a LABEL element in the form, we can use the FormCollection class provided in MVC as follows:
View section:
@using (Html.BeginForm ())
{
<text> The value you entered is:</text><span> @ViewBag .formvalue</span>
<input type= "text" name= "txtname" id= "txtname" value= ""/> <input type=
"Submit" Name= "Btnsave" id= " Btnsave "value=" Submit "/>
}"
Controller section:
[HttpPost]
Public ActionResult Index (formcollection formcol)
{
viewbag.formvalue = formcol["Txtname"];
return View ();
}
More interested in asp.net related content readers can view the site topics: "ASP.net optimization skills summary", "asp.net string operation skills Summary", "ASP.net Operation XML Skills summary", "asp.net file Operation skills Summary", "asp.net Ajax Skills Summary topic and the ASP.net caching operation skills Summary.
I hope this article will help you to ASP.net program design.