How the form is submitted and accepted in the controller in MVC
1.cshtml page form submission
2. Controller processing form submission Data 4 ways
Method 1: Use traditional request requests to fetch values
[HttpPost]
Public ActionResult Addnews ()
{
String a=request["Text1"];
String b=request["Text2"];
}
method 2:action parameter name corresponds to table cell name value one by one
[HttpPost]
Public ActionResult addnews (string text1,string text2)
{
String A=text1;
String b=text2;
}
Method 3: Read from the MVC encapsulated formcollection container
[HttpPost]
Public ActionResult addnews (formcollection form)
{
String a=form["Text1"];
String b=form["Text2"];
}
Method 4: Use the entity as the action parameter to pass in, provided that the submitted form element name corresponds to the entity attribute name one by one
[HttpPost]
Public ActionResult addnews (Usermodel user)
{
String A=user.text1;
String b=user.text2;
}
The form submission and the controller accept the data submitted by the form in ASP.