| | |
Parameter Passing with Link Buttons
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: May 2008
Posts: 25
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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"]);
}•
•
Join Date: May 2008
Posts: 25
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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
http://triaslama.wordpress.com/2008/...nd-javascript/
http://support.internetconnection.ne...y_String.shtml
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Outlook 2007 Add-in Problem in Vista
- Next Thread: Embedding a menu in a gridview cell
Views: 3331 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax anathor application asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype courier css database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdown dropdownmenu edit expose feedback flash flv form formatdecimal forms formview google grid gridview homeedition hosting identity iframe iis index javascript jquery list menu migration mono mssql multistepregistration nameisnotdeclared object objects order problem ratings refer rotatepage save search security serializesmo.table session silverlight smartcard software sql sqlserver2005 suse textbox tracking typeof unauthorized update validation vb vb.net video view virtualdirectory vista visual-studio visualstudio web webarchitecture webdevelopemnt xml youareanotmemberofthedebuggerusers






