Javascript implements the method for passing parameters in the browser window.

Source: Internet
Author: User

Javascript implements the method for passing parameters in the browser window.

A.html

<Html> 

B .html

<Html> 

Javascript enables page Jump. How can we transmit parameters?

It is not easy to transfer complex data when a js page is redirected. localStorage is used, which is different in different browsers.
A better way is to add some flag parameters to the jump link, such as the Object ID. The server directly generates the new page content or forwards the content to the new page, and then the page retrieves data from the server using ajax again.

How does javascript implement parameter transfer between frameworks?

Here are some methods for uploading values between webpages:

Transfer value between webpages
Three methods of passing values between two ASP. NET pages
Introduction
ASP. NET provides an excellent event-driven programming model, allowing developers to simplify the overall design of the application, but this also causes some inherent problems, such as the use of traditional ASP, by using the POST method, we can easily transfer values between pages. Similarly, when using the event-driven programming model ASP. NET is not that easy. Of course, we still have some methods to implement the same function. This article will try to solve this problem using different possible methods, but it is foreseeable that this article will include the querystring, session variable, and server. Transfer Method for cross-page value Transfer.

First:
QueryString
Using QuerySting to pass values between pages is already a very old mechanism. The main advantage of this method is that it is very simple to implement, however, its disadvantage is that the passed value is displayed on the address bar of the browser (Insecure), and the object cannot be passed, however, this method is a good solution when the number of transmitted values is small and the security requirements are not high. The steps for using this method are as follows:
1. Use the control to create a web form (form)
2. Create buttons and link buttons that can return the form
3. Create a character variable to save the URL in the button or link button click event.
4. Add the QueryString parameter to the saved URL.
5. Use Response. Redirect to the saved URL above
The following code snippet demonstrates how to implement this method:
Source Page code:
Private void button#click
(Object sender, System. EventArgs e)
{
String url;
Url = "anotherwebform. aspx? Name = "+ TextBox1.Text +" & email = "+ TextBox2.Text;
Response. Redirect (url );
}
Target Page code:
Private void Page_Load
(Object sender, System. EventArgs e)
{
Label1.Text = Request. QueryString ["name"];
Label2.Text = Request. QueryString ["email"];
}

Second:
Use Session Variables
Using the Session variable is another way to pass values between pages. In this example, we store the value in the control in the Session variable and then use it on another page, to transfer values between different pages. However, it should be noted that storing too much data in the Session variable will consume a lot of server resources, so you should be careful when using the session. Of course, we should also use some cleanup actions to remove unnecessary sessions to reduce unnecessary resource consumption. The general steps for transferring values using Session variables are as follows:
1. Add necessary controls to the page.
2. Create buttons and link buttons that can return the form
3. In the Click Event of a button or link button, add the control value to the session variable.
4. Use the Response. Redirect method to Redirect to another page.
5. Extract the session value from another page. Clear the value explicitly when determining that this session is not required.
The following code snippet demonstrates how to implement this method:
Source Page code:
Private void button#click
(Object sender, System. EventArgs e)
{
// Textbox1 ...... remaining full text>

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.