How to pass special characters through query string ?

Discussion in 'ASP General' started by Sobin Thomas, May 20, 2008.

  1. Sobin Thomas

    Sobin Thomas Guest

    Hi All,
    I want to pass a string that contains many special characters :) \ . _
    etc) to another page in my website
    through query string.
    In my project I have a Gridview control ,in which there is a hyperlink
    field.The Gridview 's datasource is set as a database table at runtime.The
    hyperlink filed's DataNavigateUrlFields is set to "RecordID" ,which is a
    field in my database table.The RecordID field contains many special
    characters.I want to pass the RecordID to PlayRecord.aspx page .I transfer
    the RecordID by setting Hyperlink field's Data NavigateUrlFormat string as
    PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not working as
    RecordID contains special characters.(It works if RecordID is a normal
    string).
    Hope you 'll surely have a solution.
    Thanking you in advance for your reply.
    Best Regards
    Sobin Thomas, May 20, 2008
    #1
    1. Advertising

  2. "Sobin Thomas" <> wrote in message
    news:...
    > Hi All,
    > I want to pass a string that contains many special characters :) \ . _
    > etc) to another page in my website
    > through query string.
    > In my project I have a Gridview control ,in which there is a hyperlink
    > field.The Gridview 's datasource is set as a database table at runtime.The
    > hyperlink filed's DataNavigateUrlFields is set to "RecordID" ,which is a
    > field in my database table.The RecordID field contains many special
    > characters.I want to pass the RecordID to PlayRecord.aspx page .I transfer
    > the RecordID by setting Hyperlink field's Data NavigateUrlFormat string as
    > PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not working

    as
    > RecordID contains special characters.(It works if RecordID is a normal
    > string).
    > Hope you 'll surely have a solution.
    > Thanking you in advance for your reply.


    This group is for Classic ASP. For ASP.NET questions post to
    microsoft.public.dotnet.framework.aspnet


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, May 20, 2008
    #2
    1. Advertising

  3. Sobin Thomas wrote:
    > Hi All,
    > I want to pass a string that contains many special characters :) \ . _
    > etc) to another page in my website
    > through query string.
    > In my project I have a Gridview control ,in which there is a hyperlink
    > field.The Gridview 's datasource is set as a database table at
    > runtime.The hyperlink filed's DataNavigateUrlFields is set to
    > "RecordID" ,which is a field in my database table.The RecordID field
    > contains many special characters.I want to pass the RecordID to
    > PlayRecord.aspx page .I transfer the RecordID by setting Hyperlink
    > field's Data NavigateUrlFormat string as
    > PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
    > working as RecordID contains special characters.(It works if RecordID
    > is a normal string).


    The solution is the same for dotnet as it is for COM-based ASP: use the
    urlEncode method to encode the strings being put into the querystring.
    Having said that:

    There was no way for you to know it (except maybe by browsing through some
    of the previous questions in this newsgroup before posting yours - always a
    recommended practice) , but this is a classic (COM-based) asp newsgroup.
    ASP.Net bears
    very little resemblance to classic ASP so, while you may be lucky enough to
    find a dotnet-knowledgeable person here who can answer your question, you
    can eliminate the luck factor by posting your question to a group where
    those dotnet-knowledgeable people hang out. I suggest
    microsoft.public.dotnet.framework.aspnet or the forums at www.asp.net.

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], May 20, 2008
    #3
  4. "Bob Barrows [MVP]" <> wrote in message
    news:...
    > Sobin Thomas wrote:
    > > Hi All,
    > > I want to pass a string that contains many special characters :) \ . _
    > > etc) to another page in my website
    > > through query string.
    > > In my project I have a Gridview control ,in which there is a hyperlink
    > > field.The Gridview 's datasource is set as a database table at
    > > runtime.The hyperlink filed's DataNavigateUrlFields is set to
    > > "RecordID" ,which is a field in my database table.The RecordID field
    > > contains many special characters.I want to pass the RecordID to
    > > PlayRecord.aspx page .I transfer the RecordID by setting Hyperlink
    > > field's Data NavigateUrlFormat string as
    > > PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
    > > working as RecordID contains special characters.(It works if RecordID
    > > is a normal string).

    >
    > The solution is the same for dotnet as it is for COM-based ASP: use the
    > urlEncode method to encode the strings being put into the querystring.



    How easy is that to achieve when databinding into a gridview? I don't use
    the provided controls much myself. I suspect one would need to add a field
    to the datasource that has the value UrlEncoded. Better would be to not use
    such a value and use a numeric, hash or guid instead.

    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, May 20, 2008
    #4
  5. Anthony Jones wrote:
    > "Bob Barrows [MVP]" <> wrote in message
    > news:...
    >> Sobin Thomas wrote:
    >>> Hi All,
    >>> I want to pass a string that contains many special characters :)
    >>> \ . _ etc) to another page in my website
    >>> through query string.
    >>> In my project I have a Gridview control ,in which there is a
    >>> hyperlink field.The Gridview 's datasource is set as a database
    >>> table at runtime.The hyperlink filed's DataNavigateUrlFields is set
    >>> to "RecordID" ,which is a field in my database table.The RecordID
    >>> field contains many special characters.I want to pass the RecordID
    >>> to PlayRecord.aspx page .I transfer the RecordID by setting
    >>> Hyperlink field's Data NavigateUrlFormat string as
    >>> PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
    >>> working as RecordID contains special characters.(It works if
    >>> RecordID is a normal string).

    >>
    >> The solution is the same for dotnet as it is for COM-based ASP: use
    >> the urlEncode method to encode the strings being put into the
    >> querystring.

    >
    >
    > How easy is that to achieve when databinding into a gridview? I
    > don't use the provided controls much myself.


    I hadn't really thought it through. I suppose he would have to use a
    templatefield object rather than a boundfield object so the object can
    be bound to the result of the UrlEncode function.

    > I suspect one would
    > need to add a field to the datasource that has the value UrlEncoded.


    That's one of the options I was thinking of.

    > Better would be to not use such a value and use a numeric, hash or
    > guid instead.
    >

    I can't argue with that.

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], May 20, 2008
    #5
  6. "Bob Barrows [MVP]" <> wrote in message
    news:...
    > Anthony Jones wrote:
    >> "Bob Barrows [MVP]" <> wrote in message
    >> news:...
    >>> Sobin Thomas wrote:
    >>>> Hi All,
    >>>> I want to pass a string that contains many special characters :)
    >>>> \ . _ etc) to another page in my website
    >>>> through query string.
    >>>> In my project I have a Gridview control ,in which there is a
    >>>> hyperlink field.The Gridview 's datasource is set as a database
    >>>> table at runtime.The hyperlink filed's DataNavigateUrlFields is set
    >>>> to "RecordID" ,which is a field in my database table.The RecordID
    >>>> field contains many special characters.I want to pass the RecordID
    >>>> to PlayRecord.aspx page .I transfer the RecordID by setting
    >>>> Hyperlink field's Data NavigateUrlFormat string as
    >>>> PlayRecord.aspx?RecID={0}.The problem is that, hyperlinks are not
    >>>> working as RecordID contains special characters.(It works if
    >>>> RecordID is a normal string).
    >>>
    >>> The solution is the same for dotnet as it is for COM-based ASP: use
    >>> the urlEncode method to encode the strings being put into the
    >>> querystring.

    >>
    >>
    >> How easy is that to achieve when databinding into a gridview? I
    >> don't use the provided controls much myself.

    >
    > I hadn't really thought it through. I suppose he would have to use a
    > templatefield object rather than a boundfield object so the object can
    > be bound to the result of the UrlEncode function.
    >


    Or you could simply format the value in the control's RowDataBound event....

    --
    Mike Brind
    Microsoft MVP - ASP/ASP.NET
    Mike Brind [MVP], May 21, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay
    Replies:
    3
    Views:
    4,615
    William Ryan
    Oct 31, 2003
  2. SMG
    Replies:
    20
    Views:
    16,049
    =?Utf-8?B?TWF2ZXJpY2s=?=
    May 25, 2005
  3. SMG - Idealake

    Special Characters in Query String

    SMG - Idealake, May 20, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    17,973
    Juan T. Llibre
    May 20, 2005
  4. Stefan Mueller
    Replies:
    3
    Views:
    33,001
    Stefan Mueller
    Jul 23, 2006
  5. Sunshine Valdes

    Special Characters in passed Query String

    Sunshine Valdes, Sep 8, 2003, in forum: ASP General
    Replies:
    2
    Views:
    314
    Adrienne
    Sep 11, 2003
Loading...

Share This Page