escaping quotes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike P

    #1

    escaping quotes

    Can anybody tell me what is wrong with this code? I am thinking it is
    something to do with how I am escaping the quotes.

    <img src="pix2.asp?l bmid=" & Request.QuerySt ring("LBMID") & "&LBMEmail= "
    & Request.QuerySt ring("LBMEmail" ) & """ width=1 height=1 border=0>



    *** Sent via Developersdex http://www.developersdex.com ***
  • Bob Barrows [MVP]

    #2
    Re: escaping quotes

    Mike P wrote:
    Can anybody tell me what is wrong with this code? I am thinking it is
    something to do with how I am escaping the quotes.
    >
    <img src="pix2.asp?l bmid=" & Request.QuerySt ring("LBMID") &
    "&LBMEmail= " & Request.QuerySt ring("LBMEmail" ) & """ width=1
    height=1 border=0>
    >
    >
    >
    Two things:
    You failed to delineate the server-side code from the client-side html.
    Why are you trying to inject a quote there at the end?

    Actually 3 things:
    You failed to describe your symptoms. At least view the page source after
    running the page and show us the resulting img tag, or tell us what the
    error message is.

    Anyways, the long version:

    <img src="pix2.asp?l bmid="
    <%Response.Writ e Request.QuerySt ring("LBMID") %>
    &LBMEmail=
    <%Response.Writ e Request.QuerySt ring("LBMEmail" ) %>
    " width=1 height=1 border=0>

    The shortcut that most people use:

    <img src="pix2.asp?l bmid="<%=Reques t.QueryString(" LBMID")%>
    &LBMEmail=<%=Re quest.QueryStri ng("LBMEmail")% >" width=1 height=1 border=0>

    The idea is to write the html the way it should look with hard-coded values:

    <img src="pix2.asp?l bmid=12345&LBME mail=me@abc.com " width=1 height=1
    border=0>

    Then replace the hard-coded values with the server-side script blocks. There
    is no need to do the concatenation inside the server-script blocks. Yes, you
    could have done this:

    <img src="pix2.asp?l bmid="<%=Reques t.QueryString(" LBMID") & "&LBMEmail= " &
    Request.QuerySt ring("LBMEmail" )%>" width=1 height=1 border=0>

    but it can get confusing and there really is no need to do this unless you
    are making decisions in the server-side code as to what name-value pairs are
    being included in the querystring.

    --
    Microsoft MVP - ASP/ASP.NET - 2004-2007
    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"


    Comment

    Working...