Parameter Passing with Link Buttons

Thread Solved

Join Date: May 2008
Posts: 25
Reputation: anitha joe has a little shameless behaviour in the past 
Solved Threads: 0
anitha joe anitha joe is offline Offline
Light Poster

Parameter Passing with Link Buttons

 
0
  #1
Aug 21st, 2008
Hey all,
I have 2 .aspx pages. I want to have a connection between these 2 pages through a button click event..From one of the ASP.Net books I came to know about this link buttons,whose main job is to connect 2 web pages..Well that worked fine..

Now my question is, I need to pass an integer value from first .aspx page to 2nd .aspx page..
I wrote this code in 1st aspx page..the integer variable year is the parameter that I want to pass..Now how do I receive this parameter in the 2nd page. Can I access that with the sender object on Page Load event of the second page? If anyone has the syntax for it, it would be greatly appreciated..
connect.aspx:
<asp:LinkButton ID="picUpload" runat="server" OnClick="picUpload_Click">Upload your pictures</asp:LinkButton>

connect.aspx.cs:
protected void picUpload_Click(object sender, EventArgs e)
{
int year = 1870;
Response.Redirect("upload.aspx",year);
}

Thanks
Ani
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Parameter Passing with Link Buttons

 
1
  #2
Aug 21st, 2008
For this you can use a query string or session, query string might be easiest.
connect.aspx.cs
protected void picUpload_Click(object sender, EventArgs e)
{
int year = 1870;
Response.Redirect("upload.aspx?year=" + year.ToString());
}

in the receiving page
private void Page_Load(object sender, System.EventArgs e)
{
int year = Convert.ToInt32(Request.QueryString["year"]);
}
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 25
Reputation: anitha joe has a little shameless behaviour in the past 
Solved Threads: 0
anitha joe anitha joe is offline Offline
Light Poster

Re: Parameter Passing with Link Buttons

 
0
  #3
Aug 21st, 2008
Hello dickersonka,
Thank you for ur reply..I have one more question..I tried your suggestion..But now the problem is..The second file(argument receiving file) has javascript in it..I could easily pass arguments and receive arguments as long as both pages were using aspx.cs file as their codes behind..But now when the argument receiving file has only javaScript in it, how do I receive those arguments? Do you know javascript syntax for that?
Thanks
Ani
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 138
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Parameter Passing with Link Buttons

 
0
  #4
Aug 21st, 2008
Easiest to just make it an aspx page and add the javascript to that. If you just need javascript here's a couple links on parsing the query string through javascript.

http://triaslama.wordpress.com/2008/...nd-javascript/

http://support.internetconnection.ne...y_String.shtml
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 25
Reputation: anitha joe has a little shameless behaviour in the past 
Solved Threads: 0
anitha joe anitha joe is offline Offline
Light Poster

Re: Parameter Passing with Link Buttons

 
0
  #5
Aug 22nd, 2008
Thanks Dick..It worked...
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum


Views: 3331 | Replies: 4
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC