Closed Thread
Results 1 to 4 of 4

Thread: Issue with ampersand &

  1. #1
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    Issue with ampersand &

    Hi All,

    I have a field "Status" where some of the data is:
    -In R&M

    This is the status field where the data is stored. I can get results when I search the status field using the "In R&M" selection but I'm passing the status when i'm exporting to excel file, like below.

    Code:
    location.href = "ResultsExcel.asp?RegionName=<%= sRegion %>&District=<%= strDistrict %>&Status=<%= strStatus %>
    
    Here is what I get when I pass to excel but don't get any records only the header info in the file.

    Code:
    http://server/folder/ResultsExcel.asp?RegionName=&District=&Status=In R&M
    
    I've tried adding this to my resultsexcel.asp but still no luck with returning records.

    Code:
    strStatus = Replace(Request("Status"),"&","& amp;")
    
    I'm thinking the problem is the & because I have other Status' without the & and those work just fine.

    Any help/suggestions is greatly appreciated.

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    You need to use Server.UrlEncode() to encode the querystring.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Loyal Rebelle will become famous soon enough Rebelle's Avatar
    Join Date
    Mar 2008
    Posts
    868
    Rep Power
    3

    Thanks JMurrayhead!!!!

    Using this now and all seems to be good.

    Code:
    location.href = "ResultsExcel.asp?RegionName=<%= sRegion %>&District=<%= strDistrict %&Status=<%= Server.UrlEncode(Request("Status")) %>
    

  4. #4
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    1,724
    Blog Entries
    10
    Rep Power
    11

    Quote Originally Posted by jmurrayhead View Post
    You need to use Server.UrlEncode() to encode the querystring.
    Can't give you rep so I'll just say I agree!

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO