special character "&" and " ' " in request.querystring URL

Discussion in 'ASP General' started by magix8@gmail.com, Feb 17, 2008.

  1. Guest

    Hi all,


    how can I pass the special characters as request.querystring value ?
    example like "&", since & is used in request.querystring for various
    parameters value

    It will be cut off until "pass" in text 1, for example

    let say:
    text1 = "I want to pass & chacater"

    test.asp?Text1=<%=text1%>

    should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
    work either as I tried
    I read some ppl suggested using replace method to replace "&" with
    normal letters, and at receiving, replace back with "&", but is there
    a better one ?

    Special characters like ' ' and & are having problem in
    request.querystring URL

    Any suggestions or workaround ?

    Thanks.

    cheers,
    Magix
    , Feb 17, 2008
    #1
    1. Advertising

  2. Evertjan. Guest

    wrote on 17 feb 2008 in
    microsoft.public.inetserver.asp.general:

    > how can I pass the special characters as request.querystring value ?
    > example like "&", since & is used in request.querystring for various
    > parameters value
    >
    > It will be cut off until "pass" in text 1, for example
    >
    > let say:
    > text1 = "I want to pass & chacater"
    >
    > test.asp?Text1=<%=text1%>
    >
    > should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
    > work either as I tried
    > I read some ppl suggested using replace method to replace "&" with
    > normal letters, and at receiving, replace back with "&", but is there
    > a better one ?
    >
    > Special characters like ' ' and & are having problem in
    > request.querystring URL
    >
    > Any suggestions or workaround ?


    Use VBS Escape()

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Feb 17, 2008
    #2
    1. Advertising

  3. Guest

    On Feb 17, 5:14 pm, "Evertjan." <> wrote:
    > wrote on 17 feb 2008 in
    > microsoft.public.inetserver.asp.general:
    >
    >
    >
    >
    >
    > > how can I pass the special characters as request.querystring value ?
    > > example like "&", since & is used in request.querystring for various
    > > parameters value

    >
    > > It will be cut off until "pass" in text 1, for example

    >
    > > let say:
    > > text1 = "I want to pass & chacater"

    >
    > > test.asp?Text1=<%=text1%>

    >
    > > should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
    > > work either as I tried
    > > I read some ppl suggested using replace method to replace "&" with
    > > normal letters, and at receiving, replace back with "&", but is there
    > > a better one ?

    >
    > > Special characters like ' ' and &  are having problem in
    > > request.querystring URL

    >
    > > Any suggestions or workaround ?

    >
    > Use VBS Escape()
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)- Hide quoted text -
    >
    > - Show quoted text -




    I used:
    <script>

    var vQText = document.getElementById("Text1").value;
    var result = vQText.replace(/&/gi, "%26"); // replace ampersand
    </script>

    It works fine.

    But for single quote, it doesn't seem working.
    i.e var result = vQText.replace(/'/gi, "%27"); // replace single quote
    , Feb 17, 2008
    #3
  4. Evertjan. Guest

    wrote on 17 feb 2008 in
    microsoft.public.inetserver.asp.general:

    >> > Any suggestions or workaround ?

    >>
    >> Use VBS Escape()
    >>


    [please do not quote signatures on usenet]

    > I used:
    > <script>
    >
    > var vQText = document.getElementById("Text1").value;
    > var result = vQText.replace(/&/gi, "%26"); // replace ampersand
    > </script>
    >
    > It works fine.
    >
    > But for single quote, it doesn't seem working.
    > i.e var result = vQText.replace(/'/gi, "%27"); // replace single quote


    Why noy do this serverside as I suggested?

    >> text1 = "I want to pass & chacater"
    >> test.asp?Text1=<%=text1%>


    ASP-VBS:

    <% text1 = "I want to pass & chacater" %>

    <a href = 'test.asp?Text1=<% = Escape(text1) %>'>

    or

    ASP-JS:

    <% text1 = 'I want to pass & chacater'; %>

    <a href = 'test.asp?Text1=<% = escape(text1); %>'>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Feb 17, 2008
    #4
  5. wrote on Sun, 17 Feb 2008 00:06:55 -0800 (PST):

    > Hi all,



    > how can I pass the special characters as request.querystring value ?
    > example like "&", since & is used in request.querystring for various
    > parameters value


    > It will be cut off until "pass" in text 1, for example


    > let say:
    > text1 = "I want to pass & chacater"


    > test.asp?Text1=<%=text1%>


    > should I use Server.URLEncode ? But Server.URLEncode doesn't seems to
    > work either as I tried
    > I read some ppl suggested using replace method to replace "&" with
    > normal letters, and at receiving, replace back with "&", but is there a
    > better one ?


    What didn't work with Server.URLEncode?

    Response.Write Server.URLEncode("I want to pass & character")

    spits out

    I+want+to+pass+%26+character

    which is correct.

    Did you try

    test.asp?Text1=<%=Server.URLEncode(text1)%>

    --
    Dan
    Daniel Crichton, Feb 18, 2008
    #5
    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. Daniel Bass
    Replies:
    2
    Views:
    3,700
    dave wanta
    Jul 4, 2003
  2. George
    Replies:
    5
    Views:
    6,593
    George
    Apr 2, 2004
  3. Claude Henchoz

    URL 'special character' replacements

    Claude Henchoz, Jan 9, 2006, in forum: Python
    Replies:
    6
    Views:
    623
    Claude Henchoz
    Jan 9, 2006
  4. michaaal
    Replies:
    6
    Views:
    399
    Michael D. Kersey
    Jul 15, 2003
  5. Adeel Ahmad
    Replies:
    1
    Views:
    363
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page