Querystrings different in straight HTML and delimited ASP

Discussion in 'ASP General' started by .Net Sports, Dec 24, 2009.

  1. .Net Sports

    .Net Sports Guest

    I have querystrings that are referencing the same queried object:

    HTML: <a href="?qencl=<%=qencl%>&cat=<%=qc%> ....

    ASP: Response.Write "<a href=?qencl="&qencl&"&cat="&qc&"...

    the queried object "cat" does not break up if the "cat" has spaces in
    it on the "HTML" version

    the queried object "cat" breaks off at the first space in the "ASP:
    version

    HTML = http://www.mysite.com/my.asp?qencl=sup&cat=Critical
    Infrastructure and Key Resources

    ASP: = http://www.mysite.com/my.asp?qencl=sup&cat=Critical

    not sure to what extent i need to use Server.URLEncode in this snafu

    ???
    NS
    .Net Sports, Dec 24, 2009
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed ".Net Sports"
    <> writing in news:46fdbede-f1a6-4711-952f-
    :

    > I have querystrings that are referencing the same queried object:
    >
    > HTML: <a href="?qencl=<%=qencl%>&cat=<%=qc%> ....
    >
    > ASP: Response.Write "<a href=?qencl="&qencl&"&cat="&qc&"...
    >
    > the queried object "cat" does not break up if the "cat" has spaces in
    > it on the "HTML" version
    >
    > the queried object "cat" breaks off at the first space in the "ASP:
    > version
    >
    > HTML = http://www.mysite.com/my.asp?qencl=sup&cat=Critical
    > Infrastructure and Key Resources
    >
    > ASP: = http://www.mysite.com/my.asp?qencl=sup&cat=Critical
    >
    > not sure to what extent i need to use Server.URLEncode in this snafu
    >
    > ???
    > NS
    >
    >


    dim q, r, t
    q = 1
    r = 2
    t = 3

    Response.Write "<a href=" & chr(34) & "somepage.asp?q=" & id &
    "&amp;r=" & col & "&amp;t=" & tld & chr(34) & ">somepage</a>"

    which the browser will parse as
    <a href="somepage.asp?q=1&r=2&t=3">somepage</a>

    The & character should be escaped &amp; except in the case of a
    response.redirect or server.transfer, and the quotation marks should
    remain in place. Others use double quotes, but I prefer using chr(34)
    instead - it's easier to debug.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Dec 24, 2009
    #2
    1. Advertising

  3. .Net Sports

    Dan Guest

    ".Net Sports" <> wrote in message
    news:...
    > I have querystrings that are referencing the same queried object:
    >
    > HTML: <a href="?qencl=<%=qencl%>&cat=<%=qc%> ....
    >
    > ASP: Response.Write "<a href=?qencl="&qencl&"&cat="&qc&"...
    >
    > the queried object "cat" does not break up if the "cat" has spaces in
    > it on the "HTML" version
    >
    > the queried object "cat" breaks off at the first space in the "ASP:
    > version
    >
    > HTML = http://www.mysite.com/my.asp?qencl=sup&cat=Critical
    > Infrastructure and Key Resources
    >
    > ASP: = http://www.mysite.com/my.asp?qencl=sup&cat=Critical
    >
    > not sure to what extent i need to use Server.URLEncode in this snafu
    >
    > ???
    > NS
    >



    In the latter case you are not quoting the URL, which is why a space causes
    a problem. You should never be using spaces in URLs though.

    In both case, use Server.URLEncode to encode each value, eg.

    Response.Write "<a href=""?qencl=" & Server.URLEncode(qencl) & "&cat=" &
    Server.URLEncode(qc) & ... """>"


    note that I've also added "" after the href=, this is one way to add double
    quotes into strings in ASP VBScript; another being the Chr(34) that Adrienne
    has suggested.

    --
    Dan
    Dan, Dec 30, 2009
    #3
    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. Joe Coppola

    Straight ASP problem

    Joe Coppola, Jun 14, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    413
    Joe Coppola
    Jun 14, 2004
  2. Replies:
    11
    Views:
    694
    Danny Tuppeny
    Oct 29, 2005
  3. RyanL
    Replies:
    6
    Views:
    662
    Paul McGuire
    Aug 28, 2007
  4. Replies:
    1
    Views:
    358
    Joe Fawcett
    May 13, 2008
  5. anagai
    Replies:
    1
    Views:
    127
Loading...

Share This Page