How to submit, PASS Parameters, and authenticate an html page

Source: Internet
Author: User

Because the project needs to do a set of surveys, but the customer requires that the questions of the questionnaire be purely html tags, so there are a series of problems.

1. How to submit the page

After the user has completed the survey, how can I submit the survey results?

2. How to pass parameters to the page

After multiple people submit the same questionnaire, the administrator can check the questionnaire and transmit parameters to ensure that the data is the questionnaire of a specific person. In fact, this problem can be solved by using the simplest query string in asp.net, but how to pass parameters in pure html?

3. How to verify user identity

After a user logs in, he can answer the question. How can I verify whether the user is logged in?

 


Is the entire system implemented using html? Can this be done? It doesn't seem to work. After all, the submitted data needs to be saved to the database. This may not be done simply in html.

Therefore, the basic idea is that the front-end uses html static Web pages, but the back-end must use csharp code.

 


1. How to submit the page


In fact, only html can be submitted, mainly through the tag form.

For example, the following code is submitted to savedata. after aspx, you can obtain all the data input by the user and save the data to the database after processing. You can submit the data through ajax or submit the data by using the label with the input type as submit.

<Input type = "submit" value = "Submit"/>

 

<form action="savedata.aspx" method="post">   <p>First name: <input type="text" name="fname" /></p>   <p>Last name: <input type="text" name="lname" /></p>   <input type="submit" value="Submit" /> </form> <form action="savedata.aspx" method="post">  <p>First name: <input type="text" name="fname" /></p>  <p>Last name: <input type="text" name="lname" /></p>  <input type="submit" value="Submit" /></form>


2. How to pass parameters to the page

In asp.net, the simplest way to pass parameters to a page is to query strings, but a pure html web page is a static Web page without the background of the corresponding page. how to pass Parameters

For example, in the same set of questionnaires, Zhang San and Li Si answered the questionnaire. The administrator wants to view the questionnaire of Zhang San. How can he assign the answers of Zhang San to the questions of the questionnaire?

Because html is a static page, to read data, you must use ajax to dynamically read the answer and then modify the static page. But how can we pass parameters that represent a person?

In fact, it is still through the query string, but the method for analyzing and querying strings changes from the background to the foreground, to the analysis and query string through js, and then read data through ajax.


 

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 "";    } }  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 another way, because reading data through the background, so you can obtain parameters based on the information in the Session, but if there is no relevant information in the Session, you can only query strings.

For example, you can only query strings.

 


3. How to verify user identity


Since there is no way for the entire system to be completed simply using html, the front-end display is pure html, and the back-end is csharp code, there will naturally be Session, and of course the user's identity can be verified. To determine whether a static html page has expired, you can call the background method through ajax to determine whether the user has logged on or expired based on the existence of the Session.

 


 

Related Article

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.