Go Back   Wiki NewForum > Career Forum (Documents/Tutorials/Advice) > Tech Forum & Tutorial > ASP.NET Forum & Tutorial

Reply
Views: 973 Source: CNN18.com, India-Forums, TellyChakkar, India, Times of India, Youtube, BollywoodLife, Rediff  
Thread Tools Rate Thread Display Modes
  #1  
Old 05-31-2009, 07:52 AM
bholus7 bholus7 is offline
Banned
 
Join Date:
Apr 2009
Posts: 1,322
Default Explain 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

This html addresses use QueryString property to pass values between pages.

From the URL above the information obtained is:

form.aspx: which is the destination page for your browser.
Param1 is the first parameter, the value of which is set to career
Param2 is the first parameter, the value of which is set to ride

The ? marks the beginning of the QueryString
& is used as a separator between parameters.

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

The above code is a submit ****on event handler and it sends the values of the query string to the second page.

The following code demonstrates how to retrieve these valus 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]);
}

Ads
Reply With Quote
Reply

New topics in ASP.NET Forum & Tutorial

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
asp web stats