Sponsored By
MindStick SurveyManager
Advertise with Us
Advertisement
Advertise with Us
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
   

Home >> .Net >> C# >> Problem in passing value from one page to other page in ASP.NET
Author Post

John Smith


Total Post: 51
Member Since: 9/27/2010
Points: 332
Problem in passing value from one page to other page in ASP.NET
Posted On: 9/28/2010 10:08:33 AM
Hi,
Could you please let me know how to pass value from one page to other through Query String as I am new in ASP.NET.
Your help will be appreciated!

Thanks,
John
Modified On: 9/29/2010 9:38:56 AM
Author Post

Amit Singh


Total Post: 104
Member Since: 8/8/2010
Points: 702
Re: Problem in passing value from one page to other page in ASP.NET
Posted On: 9/29/2010 9:44:18 AM
Report Abuse Answer
We pass the value from one page to another page by query string, we write the syntax as

1) Response.Redirect("Default.aspx?query=John Smith");

where "query" is query string variable and "John Smith" is the string value for query variable.
Now we access the value on Default.aspx page as

string query=Request.QueryString["query"].toString();

2) we pass the multiple parameter by query string then we write the syntax as

Response.Redirect("Default.aspx?query1=John Smith &query2=krish");

Now we access the value on Default.aspx page as

string query1=Request.QueryString["query1"].toString();
string query2=Request.QueryString["query2"].toString();


or
string query1=Request.QueryString[0].toString();
string query2=Request.QueryString[1].toString();


or
string query1=Request.Params[0].toString();
string query2=Request.Params[1].toString();


3) We pass the any value by query string as

string str="JohnSmith";
Response.Redirect("Default.aspx?query="+str);


And access these value on another page by

string query=Request.QueryString["query"].toString();
Modified On: 9/29/2010 9:46:11 AM
Author Post

Haider M Rizvi


Total Post: 40
Member Since: 6/6/2010
Points: 291
Re: Problem in passing value from one page to other page in ASP.NET
Posted On: 9/29/2010 10:09:49 AM
Report Abuse Answer
If you want to pass value from one page to another using Query string then just add name of query followed by its value.

example

supose you have two pages a.aspx and b.aspx and you want to pass value from a.aspx to b.aspx then instead of just redirecting to page b.aspx, redirect to b.aspx as b.aspx?Name=Haider

Here Name is name of Query String and Haider is value you want to pass.

Now to access this value in b.aspx use

string strName = Request.QueryString["Name"].toString();

Author Post

John Smith


Total Post: 51
Member Since: 9/27/2010
Points: 332
Re: Re: Problem in passing value from one page to other page in ASP.NET
Posted On: 9/30/2010 11:00:40 AM
thx for your time ..:)
Report Abuse Form
Reason:    
 
Total Online Users: 7466
Advertisement
MindStick DataConverter
Advertise with Us
  
Copyright © 2009 - 2013MindStick. All Rights Reserved.