You can use Query String to pass parameter from one page to another, with Response.Redirect() method.
It is really a very easy to implement, the thing is, first of all you have to build a query string.....Query String is actually a way to passing data from one page to another page in the form of Key Value pair e.g
www.yourwebsite.com/YourPage.aspx?UserID=1&Name=Ritao ,
nsatterlee
Member
32 Points
22 Posts
Response.Redirect in C# for page to page parameter passing
May 02, 2007 12:35 PM|LINK
Looking for examples of this, but can't find anything specific. I'm new to ASP.NET, and C# at the same time... so I'm struggling to get it right...
Thanks, Nick
“To teach is to learn twice.” – Joseph Joubert
mariop77
Participant
800 Points
130 Posts
Re: Response.Redirect in C# for page to page parameter passing
May 02, 2007 01:32 PM|LINK
Hi. You can pass parameters in the querystring:
Response.redirect("otherpage.aspx?id=5")
And in "otherpage.aspx" read the values:
int id = Response.QueryString("id")
Haissam
All-Star
37421 Points
5632 Posts
Re: Response.Redirect in C# for page to page parameter passing
May 02, 2007 01:41 PM|LINK
Try the below code to redirect to a webform and pass a query string parameter
Response.Redirect("WebForm2.aspx?id=123");
And on webform2.aspx, if you want to retreive the value for id use the below code
C#
string id = Request.QueryString["id"];
HC
MCAD.NET
| Blog |
akhhttar
Contributor
6506 Points
963 Posts
Re: Response.Redirect in C# for page to page parameter passing
May 02, 2007 01:46 PM|LINK
Hi Dear,
You can use Query String to pass parameter from one page to another, with Response.Redirect() method.
It is really a very easy to implement, the thing is, first of all you have to build a query string.....Query String is actually a way to passing data from one page to another page in the form of Key Value pair e.g www.yourwebsite.com/YourPage.aspx?UserID=1&Name=Ritao ,
Response.Redirect("AnotherPage.aspx?UserID" + strUserID + "&Name=" + strName )On Source Page
You can access Query String values easily by using Request.QueryString collection...
if you want to get UserID and Name values in the above URL....use the following code in AnotherPage.aspx Page_Load event
dim strUserID as string = Request.QueryString("UserID")
dim strName as string = Request.QueryString("Name")
THanks
Best Regards,
MUhammad AKhtar Sheikh
My Blog
stapes
Member
121 Points
124 Posts
Re: Response.Redirect in C# for page to page parameter passing
Apr 03, 2009 12:48 PM|LINK
Error 4 'System.Web.HttpResponse' does not contain a definition for 'QueryString'
Haissam
All-Star
37421 Points
5632 Posts
Re: Response.Redirect in C# for page to page parameter passing
Apr 03, 2009 02:01 PM|LINK
You should using the Request object and not Response object to retrieve the query string parameters!
MCAD.NET
| Blog |
Gabitza
Member
2 Points
1 Post
Re: Response.Redirect in C# for page to page parameter passing
Nov 14, 2009 03:57 PM|LINK
Hello. I'm trying to pass parameters to a page to another and I wrote the following code:
<asp:HyperLink ID="LinkToActivity" runat="server" NavigateUrl='"~/ActivityPage.aspx?Name="+<%#Eval("ActivityName") %>'> <%#Eval("ActivityName") %> </asp:HyperLink>
The error is: System.ArgumentException: Illegal characters in path.
Please help me :(
azermann
Member
85 Points
49 Posts
Re: Response.Redirect in C# for page to page parameter passing
Sep 02, 2010 12:51 PM|LINK
Hi Gabitza try this one
<asp:HyperLink ID="LinkToActivity" runat="server" Text='<%# Eval("ActivityName") %>' NavigateUrl='<%# "~/ActivityPage.aspx?Name=" +Eval("ActivityName") %>' />