Recommended: ASP instance hangs QQ's web page source code ASP/PHP This code is suitable for you to use on the website, and ordinary friends can ignore this thing! ASP: CODE: [Copy to clipboard] <%dim objXMLHTTP, qq, pwd qq = 10000
introduce
We always encounter situations where we need to pass values from one page to another. In this article, you are shown several ways to pass values from one page to another. In this example, the created web page consists of a text control and several button controls. The data entered in the text box is passed from one web page to another by different methods identified in the button control.
Response.Redirect
Let's first look at how to pass data using the Response.Redirect method. This is the easiest way of them. Enter some data in the text box, and when you enter the data, press the Respose.Redirect button. We get a prompt that sometimes we want to pass another webpage in the catch program, meaning that exceptions are caught and passed to another webpage. If you try to do this, it will give you a System.Threading exception. Because you want to leave behind a thread to pass data to another web page, this exception will be thrown.
Response.Redirect(WebForm5.aspx,false);
This statement tells the compiler to locate WebForm5.aspx, where false means that the current web page cannot end what you are doing. You should look at the System.Threading class where the thread issues commands. Below, take a look at the C# code for the button event. The name of the txtName text control, the value in the text box is passed to a web page called WebForm5.aspx. exist? The following Name symbol is just a temporary response variable, which maintains the value of the text.
private void Button1_Click(object sender, System.EventArgs e) { // Value sent using HttpResponse Response.Redirect(WebForm5.aspx?Name= txtName.Text); } |
if (Request.QueryString[Name]!= null) Label3.Text = Request.QueryString[Name]; |
Cookies
Next use cookies. Cookies are created on the server side, but are omitted on the client side. In the click event of this Cookies button, write the following code:
HttpCookie cName = new HttpCookie(Name); cName.Value = txtName.Text; Response.Cookies.Add(cName); Response.Redirect(WebForm5.aspx); |
First, create a cookie named cName. Since an instance of a cookie can have many values, tell the compiler that this cookie holds the Name value. We assign it to TextBox and then add it to the Response stream at the end, and then pass it to other web pages using the Response.Redirect method.
Let's see how we get the cookie value passed by another webpage.
if (Request.Cookies[Name] != null ) Label3.Text = Request.Cookies[Name].Value; |
As you can see, we used the same method as we did before. We just used Request.Cookies inside Request.QueryString. Note that some browsers do not receive cookies.
Share: How to prevent sensitive information from being extracted from the page Emails published on web pages are often automatically extracted by some tools, and some illegal users will use the extracted email to send spam. Most of these tools are searching for the information behind the mailto: or the letter before and after @ in the link
2 pages in total Previous page 12 Next page