How to pass a querystring from an .asp page to aspx page

Explain how to pass a querystring from an .asp page to aspx page.

Consider the following URL:

http://localhost/form.aspx?param1=career&param2=ride

- In the above link, the html addresses use QueryString property to pass values between pages.

From the above URL the information obtained is:

- The 'form.aspx' is the destination page for your browser.
- The 'Param1' is the first parameter, the value of which is set to career.
- The 'Param2' is the second parameter, the value of which is set to ride
- The '?' marks the beginning of the QueryString and '&' is used as a separator between parameters.

Example:

private void formButtonSubmit_Click(object sender, System.EventArgs e)
{
   Response.Redirect("form.aspx?Param1=" +
   this.formTextfieldParam1.Text + "&Param2=" +
   this. formTextfieldParam2.Text);
}

- In the above example, is a submit button event handler and it sends the values of the query string to the second page.

The following code demonstrates how to retrieve these values on the second page:

private void Page_Load(object sender, System.EventArgs e)
{
   this.form2TextField1.Text = Request.QueryString["Param1"];
   this. form2TextField2.Text = Request.QueryString["Param2"];
}

You can also use the following method to retrieve the parameters in the string:

for (int i =0;i < Request.QueryString.Count;i++)
{
   Response.Write(Request.QueryString[i]);
}
Overview of the .NET Compact Framework
.NET Compact Framework - .NET Compact Framework is a scaled down versions of .NET framework for supporting Windows CE based mobile....
What is Language Integrated Query (LINQ)?
Language Integrated Query (LINQ) - LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations....
What are access modifiers?
ASP.NET - What are access modifiers? - Access modifiers are used to control the scope of type members..
Post your comment