Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET & Ajax: query string parameters using ISO-8859-1 encoding
    primarykey
    data
    text
    <p>Here's another one for you to help me solve: I have an ASP.NET website that uses AJAX (asynchronous) calls to am <code>.ashx</code> handler, passing a <em>query string</em> parameter to get some information from the database.</p> <p>Here's an example of how it works:</p> <p><em>Client-side</em> (Javascript) <em>code snippet</em> that makes the asynchronous call to the handler:</p> <pre><code>/* Capture selected value from a DropDownBox */ var dropdown = document.getElementById(DropDownID); var selectedValue = dropdown.options[dropdown.selectedIndex].value; /* Make the call to the handler */ var url = "MyHandler.ashx?param=" + selectedValue; var ajaxObj = new Ajax(); ajaxObj.doRequest(url, MyCallback, args, connectionFailed); </code></pre> <p>When I load the <code>webform</code> (that contains this AJAX call) for the first time, it sends the right query string to the handler (I checked it using debug in Visual Studio), like <code>param = Street Joseph Blíss</code>. That's the right behavior I want it to have.</p> <p>The thing is that when I load that <code>webform</code> again (and all subsequent times), that <code>í</code> character from "Blíss" appears in server-side as <code>í-</code>. As that's the key from the entity I'm trying to select on server-side database access script, it doesn't work as it worked on 1st <code>webform</code> load.</p> <p>I tried encoding the <em>query string</em> on <em>client-side</em> and decoding it on <em>server-side</em>, using something like this:</p> <p><em>Client-side</em> (Javascript):</p> <pre><code>var encodedParam = encodeURIComponent(selectedValue); /* Make the call to the handler */ var url = "MyHandler.ashx?param=" + encodedParam ; </code></pre> <p><em>Server-side</em> (ASP.NET, C#):</p> <pre><code>string encodedParam = context.Request.QueryString["param"]; string value = HttpUtility.UrlDecode(encodedParam, Encoding.ASCII); </code></pre> <p>...but I had no luck with it and the problem still remains. Any help?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload