I. Interaction
II. Specific implementation
Requirements: 1. enter the name of the submitted interface on the client, as shown in figure 2.1.
2. Use the request keyword on the acceptor, as shown in figure 2.2.
Figure:
Overall diagram:
Submission end:
Acceptor:
Example: Submit the values in the text box txtusername and txtuserpwd in the login.htm interface to login. aspx for receiving
Code in login.htm:
<Body> <Form ID = "form1" method = "Post" Action = "login. aspx "> <Table Style =" width: 100%; "> <tr> <TD width =" 100 "> User Name: </TD> <TD width = "150"> <input id = "txtusername" name = "txtusername" type = "text"/> </TD> </tr> <tr> <TD class = "style1" width = "100"> password: </TD> <TD class = "style1" width = "150"> <input id = "txtuserpwd" name = "txtuserpwd" type = "text"/> </TD> </tr> <TD colspan = "2" align = "center"> <input id = "submit1" type = "Submit" value = "Submit"/> <input id = "submit2" type = "Submit" value = "quit"/> </TD> </tr> </table> </form> </body>
Code in login. aspx:
Protected void page_load (Object sender, eventargs e) {string username = request. form ["txtusername"]. tostring (); string userpwd = request. form ["txtuserpwd"]. tostring (); If (username = "lsz" & userpwd = "lsz") {response. write ("welcome to the website");} else {response. write ("incorrect user name and password ");}}
3. Error Accumulation
1. In the submit interface, you can use "Post" or "get" to submit. The difference between the two is that the statements at the receiving end are different.
post: Request[""].ToString(); Request[""].Form.Get("").ToString();
get: Request.QueryString[""].ToString();
If the submit interface uses the keyword "Post" and the receiving end uses the get keyword receiving statement, the following error occurs:
2. the name in the receiver [""] is the name of the submitter "name", not the name of the "ID.
In general, ID is a special identifier. When used, you can directly reference the name corresponding to the ID, but it does not work here and must have a name. This error is very small. It took me two days to solve it...
Error message: