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

Recommended Answers

All 4 Replies

For this you can use a query string or session, query string might be easiest.

[B]connect.aspx.cs[/B]
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"]);
}
commented: Really Helpful +1

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

Thanks Dick..It worked...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.