How HTML pages submit, pass parameters, and authenticate identities

Source: Internet
Author: User
Tags html page html tags

Requirements must be pure HTML tags, simple HTML page How to submit, pass parameters, as well as identity verification, the following with a large share of the above series is how to achieve, there is a need for friends can refer to, I hope to help you

Because the project needs to do a set of questionnaires, but the customer asked the questionnaire question, must be a pure HTML tag, so faced with a series of problems

1 How the page is submitted

User completed the questionnaire, the results of the survey how to submit?

2 How to pass parameters to a page

The same questionnaire, many individuals submitted, managers to view the questionnaire, how to pass the parameters, to ensure that the data to see is designated a person's questionnaire. In fact, this problem, the simplest query string in asp.net can be solved, but in pure HTML, how to pass parameters?

3 How to authenticate a user

After the user landing, to answer the test, how to verify the user is logged in?

The entire system uses HTML implementations? It doesn't seem to work, after all, the submitted data needs to be saved to the database, which I'm afraid is not pure HTML can do.

So the basic idea is that the front desk all use HTML static page, but the backstage must use CSharp code to cooperate.

1 How the page is submitted

In fact, pure HTML can be submitted, mainly through the label form.

For example, the following code, after submitting to the savedata.aspx, you can get all the data entered by the user, after processing to save to the database, can be submitted through Ajax, or by the type of input for submit tags submitted.

Copy Code

The code is as follows:

Copy Code

The code is as follows:

The name:

Last Name:

2 How to pass parameters to a page

In asp.net to pass parameters to the page in fact, the simplest is through the query string, but pure HTML page is static page, no corresponding page background, how to pass parameters

For example, the same set of questionnaires, John, Dick All answered the questionnaire, the administrator to see the John Questionnaire, how to John the answer to the questionnaire again assigned to the questions?

Because HTML is a static page, to read the data, you must dynamically read the answer through Ajax, and then modify the static page. But how do you pass the argument that represents a certain person?

In fact, the query string, but the method of parsing the query string from the background into the foreground, into a JS to analyze the query string, and then read the data through Ajax.

Copy Code

The code is as follows:

function querystring (name)

{

var surl = Window.location.search

var re = new RegExp ("+name+" = ([^&?] +) "," IG ");

var result= re.exec (sURL);

if (result)

{

var temp= result[0].split (' = ');

return temp[1];

}

Else

{

Return "";

}

}

Of course there is a way, because the reading data is to go through the background, so you can according to the information in the session to get the parameters, but if there is no relevant information in the session, you can only through the way of query string.

Examples here, for example, can only be done by querying the string.

3 How to authenticate a user

Since the whole system has no way to just use HTML to complete, foreground display is pure HTML, backstage is CSharp code, nature also exists session, of course, can authenticate user identity. If you need to determine whether a static HTML page expires, you can invoke the backend method via Ajax, depending on whether the session exists to determine whether the user is logged in and whether the expiration of the judgment.

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.