Response.Redirect in C# for page to page parameter passing

Last post 11-14-2009 11:57 AM by Gabitza. 6 replies.

Sort Posts:

  • Response.Redirect in C# for page to page parameter passing

    05-02-2007, 8:35 AM
    • Member
      32 point Member
    • nsatterlee
    • Member since 01-19-2007, 10:10 PM
    • Posts 22

    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

    Thanks...


    β€œTo teach is to learn twice.” – Joseph Joubert
  • Re: Response.Redirect in C# for page to page parameter passing

    05-02-2007, 9:32 AM
    • Participant
      790 point Participant
    • mariop77
    • Member since 03-13-2007, 7:27 PM
    • Bogota
    • Posts 130

    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")

  • Re: Response.Redirect in C# for page to page parameter passing

    05-02-2007, 9:41 AM
    Answer
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 6:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    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

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: Response.Redirect in C# for page to page parameter passing

    05-02-2007, 9:46 AM
    • Contributor
      2,367 point Contributor
    • akhhttar
    • Member since 02-14-2007, 8:17 AM
    • Pakistan - Lahore
    • Posts 352

    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

    Lets resolve the problem together.

    Please remember to mark the appropriate replies as answer after your question is solved, thanks

    My Blog
  • Re: Response.Redirect in C# for page to page parameter passing

    04-03-2009, 8:48 AM
    • Member
      39 point Member
    • stapes
    • Member since 11-18-2006, 11:25 PM
    • Posts 55

    Error 4 'System.Web.HttpResponse' does not contain a definition for 'QueryString' 

  • Re: Response.Redirect in C# for page to page parameter passing

    04-03-2009, 10:01 AM
    • All-Star
      37,391 point All-Star
    • Haissam
    • Member since 10-05-2006, 6:25 AM
    • Beirut - Lebanon
    • Posts 5,632

    You should using the Request object and not Response object to retrieve the query string parameters!

    Haissam Abdul Malak
    MCAD.NET
    | Blog |
  • Re: Response.Redirect in C# for page to page parameter passing

    11-14-2009, 11:57 AM
    • Member
      2 point Member
    • Gabitza
    • Member since 11-14-2009, 11:53 AM
    • Posts 1

    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 :(

Page 1 of 1 (7 items)