Interaction process between the server and the client

Source: Internet
Author: User


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:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.