1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Passing a query string from one page to another C# .NET

Discussion in 'C#' started by j4v3d, Oct 27, 2012.

  1. #1
    Hi

    Im trying to find out how to create a query string an assign to content on a page - so for example i have a list of bookings with event title, category and location, and on each list element there is a book now button that will popup and display a form with the values already showing in the input fields. I want to pass those details using hidden input fields but im slighlty confused on how to go about this?

    Most examples i have seen they show the URL with the query string in there - dont know whether this is pre-loaded or is loaded when they do

    Code:
    [COLOR=#333333]Response.Redirect("www.url.com?contenthere");[/COLOR]
    Code (markup):
    I know you can use

    Code:
    [COLOR=#333333]string site = Request.QueryString["value"];[/COLOR]
    Code (markup):
    Any guidance would be appreciated.

    Thanks.
     
    j4v3d, Oct 27, 2012 IP
  2. sandeepdude

    sandeepdude Well-Known Member

    Messages:
    1,741
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    So if I am getting your question correct,You need to pass variables from one page to another in a secured way such that it is not visible in the address bar of the browser.

    In this case,I can think of to ways
    1) encrypt the query string
    2) use Session state instead of querystring.

    I would go with option 2 if i were you :)..let me know if this helps...
     
    sandeepdude, Oct 27, 2012 IP
  3. j4v3d

    j4v3d Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes i will be using query string only and then passing this to the next page and storing them using input hidden fields so you cant see them.

    Any examples?

    Session state wont be required in this case.
     
    j4v3d, Oct 28, 2012 IP
  4. anurag355

    anurag355 Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    3
    #4
    Passing Query String in Asp.net on button click
    qs is name of query string, Default.aspx is the page where you want to
    receive the query string
    Response.Redirect("Default2.aspx?qs="+s);

    how to get query string
    get is a string type variable
    get = Request.QueryString["qs"];
     
    anurag355, Jan 25, 2013 IP
  5. akshaykalia

    akshaykalia Member

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #5
    Hi,
    I got little confused by your question. You said you would open a pop-up with all details on the page itself. Then why would you be redirecting any parameters to another page ? What I think you are trying to achieve is something like when you click on any username on DP. It opens a modal pop-up with all the details.
    If that is what you are looking for, you can achieve that using AJAX and JQuery.
     
    akshaykalia, Feb 21, 2013 IP
  6. annaharris

    annaharris Active Member

    Messages:
    119
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    51
    #6
    You should use query string. I think it's the best option. You can pass data from one to another with using query string after that store the data in a hidden field on the second page to retrieve that information.
     
    annaharris, Mar 28, 2013 IP
  7. annaharris

    annaharris Active Member

    Messages:
    119
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    51
    #7
    You should use query string. I think it's the best option. You can pass data from one to another with using query string after that store the data in a hidden field on the second page to retrieve that information.
     
    annaharris, Mar 28, 2013 IP
  8. sbglobal79

    sbglobal79 Banned

    Messages:
    724
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    55
    #8
    There are many option to pass value from one page to other. some are as below:

    1. query-string
    2. session
     
    sbglobal79, Apr 15, 2013 IP
  9. annaharris

    annaharris Active Member

    Messages:
    119
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    51
    #9
    Use Session state for passing variables, that will keep your data secured.
     
    annaharris, Apr 30, 2013 IP
  10. EchoTek

    EchoTek Banned

    Messages:
    27
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    28
    #10
    I would advice you to use session for this so you can secure your variables query string will be displayed in the addressbar of the browser
     
    EchoTek, May 7, 2013 IP
  11. wren11

    wren11 Active Member

    Messages:
    89
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    53
    #11
    you could temporary store it inside the application state?

    dynamic obj = Application["key"] == null ? Application["key"] = new { test = "j" } : Application["key"];
    Code (markup):
     
    wren11, May 7, 2013 IP
  12. topcoder

    topcoder Well-Known Member

    Messages:
    124
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    138
    #12
    You have many different ways to pass state data, but those options can be limited based on your state mechanism that you use..

    But yes passing via a QueryString works in all cases (If it's not sensitive data).

    Arurag55 example is what you want to follow.
     
    topcoder, May 9, 2013 IP