query string doubt in aps.net andC#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    query string doubt in aps.net andC#

    Hi,

    I redirect to a page in the below manner

    Client.aspx?FRO MDATE=" + text3 + "&TODATE=" + text4 + "&STOP=" + text24 + "&MAIL=" + text1

    I came to notice that we cannot pass the character #,
    if we pass the character # the characters succeeding that got truncated.

    Is this ok. Or do we have some other way of sending querystrings which consists of the character #
  • balame2004
    New Member
    • Mar 2008
    • 142

    #2
    Originally posted by cmrhema
    Hi,

    I redirect to a page in the below manner

    Client.aspx?FRO MDATE=" + text3 + "&TODATE=" + text4 + "&STOP=" + text24 + "&MAIL=" + text1

    I came to notice that we cannot pass the character #,
    if we pass the character # the characters succeeding that got truncated.

    Is this ok. Or do we have some other way of sending querystrings which consists of the character #
    Hi,

    Have you tried session object?

    session object is used to pass information between web pages within an web application. It is good way to transfer complicated and large objects.

    Cheers,
    Balaji U

    Comment

    • kunal pawar
      Contributor
      • Oct 2007
      • 297

      #3
      right u can not pass # in querystring but u can pass its code through url and then decode it.
      Other solution is use hidden variables

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        The Session object is a really good idea. You could create a custom class with attributes of all the variables you need to pass with the query string, and then pass an instance of that object. Or, you could pass several strings, and they will be hidden from the user, so it is more hack-proof. You can use the session object by using:
        Session["object_nam e"];
        "object_nam e" can be whatever you want.

        But if you do want to use query strings, use the Server.UrlEncod e/Server.UrlDecod e methods.

        Example:

        Change :
        [code=cpp]
        //c# code
        //string url = "Client.aspx?FR OMDATE=" + text3;
        //change to:
        string url = "Client.aspx?FR OMDATE=" + Server.UrlEncod e(text3);
        [/code]
        And on the other page,
        [code=cpp]
        //c# code
        string fromdate = Server.UrlDecod e(Request.Query String["FROMDATE"]);
        [/code]

        Comment

        • cmrhema
          Contributor
          • Jan 2007
          • 375

          #5
          Originally posted by insertAlias
          The Session object is a really good idea. You could create a custom class with attributes of all the variables you need to pass with the query string, and then pass an instance of that object. Or, you could pass several strings, and they will be hidden from the user, so it is more hack-proof. You can use the session object by using:
          Session["object_nam e"];
          "object_nam e" can be whatever you want.

          But if you do want to use query strings, use the Server.UrlEncod e/Server.UrlDecod e methods.

          Example:

          Change :
          [code=cpp]
          //c# code
          //string url = "Client.aspx?FR OMDATE=" + text3;
          //change to:
          string url = "Client.aspx?FR OMDATE=" + Server.UrlEncod e(text3);
          [/code]
          And on the other page,
          [code=cpp]
          //c# code
          string fromdate = Server.UrlDecod e(Request.Query String["FROMDATE"]);
          [/code]

          Thank you all for your replies

          Comment

          Working...