HTML form submission method
<Form action = "receive data page" method = "Post"> HTML forms use HTML controls.
For a common HTML form, it has two important attributes: Action and method. The action attribute specifies which of the following statements is used after the current form is submittedProgramThis processing program can be any dynamic web page or servlet or CGI (Common Gateway Interface). In Asp.net, it is generally processed by aspx pages. The method attribute specifies the form submission method. It has two possible values: Get and post.
Server form
Compared with HTML forms, server forms have one more runat = "server" tag, for example, <Form ID = "form1" runat = "server">
In the form on the server side, you do not need to specify the action attribute, indicating that the current page is used for processing. You can also choose not to specify the method attribute. By default, the form is submitted in post mode. In server forms, we can not only use HTML controls, but also HTML server controls and Asp.net controls. Note that there may be multiple
Runat = "server" indicates the form, but only one server form is allowed.
1. Get method:
<Form ID = "form1" runat = "server" method = "get">
Ii. Post method:
<Form ID = "form1" runat = "server" method = "Post">
It mainly depends on the changes in the address bar.
====================
Value
Protected Void Btnsubmit_click ( Object Sender, eventargs E)
{
// Request. form cannot get the value
// String strname = request. Form ["txtname"];
// String strpasword = request. Form ["txtpassword"];
// Request and request. querystring values can be obtained.
String Strname = Request [ " Txtname " ];
String Strpasword = Request [ " Txtpassword " ];
// String strname = request. querystring ["txtname"];
// String strpasword = request. querystring ["txtpassword"];
This . Label3.text = " User name: " + Strname + " " + " Password: " + Strpasword; Server. Transfer ("info. aspx? Name = "+ strname +" & Password = "+ strpasword );
// Response. Redirect ("info. aspx? Name = "+ strname +" & Password = "+ strpasword );
}
Differences between server. Transfer and response. Redirect for page Jump
Redirect Mode
There is a difference between Chinese and numbers, and numbers are displayed directly. There is no difference between the Redirect get and post methods.
Transfer Mode
However, the transfer method, get and post methods are different. See the difference between get and post methods above. The default method is post.
==============================
Summary:
(1) The parameter names and parameter values are displayed in the address bar of the form submitted in get mode, but not in post mode.
(2) there is a limit on the maximum number of characters that can be entered in the address bar of the browser. Therefore, the get method cannot be used to submit a form with more parameter values, but the POST method does not.
The following common methods are used to obtain the value of a control (whether a server control or an HTML Control:
Obtaining Method |
Form submission method |
Request. querystring ["Control name"] |
Suitable for forms submitted in get Mode |
Request. Form ["Control name"] |
Suitable for forms submitted in post Mode |
Request ["Control name"] |
Forms suitable for both get and post submission |
From the above we can see that the request ["Control name"] method is feasible for both get and post methods, so we can use this method to handle all submitted forms.