Ampersand in querystring

Discussion in 'ASP .Net' started by Joe Fallon, Dec 15, 2006.

  1. Joe Fallon

    Joe Fallon Guest

    I Googled this topic and everyone says to use Server.UrlEncode.
    No sweat - I did that.
    Still doesn't work right though!

    Could use some advice.

    On the page where I build the link I have code like this for Name="A&S".
    Hy1.NavigateUrl = "javascript:CenteredWin('MyPage.aspx?keyvalue=" &
    Server.UrlEncode(mData.Name) & "','MyPage',600,500);"

    This renders as:
    <a id="Hyl1"
    href="javascript:CenteredWin('MyPage'.aspx?keyvalue=A%26S','MyPage',600,500);">A&S</a>

    When I click the link the receiving page tries to get the value from the
    querystring:

    mName = Request.QueryString("keyvalue")

    But instead of mName="A&S" it is only mName="A".

    I thought the URLEncoding was supposed to fix this.

    Why is it still broken?
     
    Joe Fallon, Dec 15, 2006
    #1
    1. Advertisements

  2. Joe Fallon

    Jon Paal Guest

    decode it before you use it.
     
    Jon Paal, Dec 16, 2006
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.