javascript - ASP.NET & Ajax: query string parameters using ISO-8859-1 encoding -


Here's another one to help you solve: I have an ASP.NET website that uses AJAX (asynchronous ) Calls the .hx handler passing the query string parameter to get some information from the database.

This is an example of how it works:

customer-side (javascript) code snippet that handler asynchronous Creates a call: Capture the selected value from

  / * a dropdown box * / var dropdown = document.getElementById (dropdown id); Var selectedValue = dropdown.options [dropdown.selectedIndex] .value; / * Call the handler / var url = "MyHandler.ashx? Param =" + selectedValue; Var ajaxObj = new Ajax (); AjaxObj.doRequest (URL, micrback, args, connection file);  

When I load the webform (which includes this AJAX call) for the first time, it sends the handler to the correct query string (I debug it I check in Visual Studio), like param = street yusuf blais . This is the right behavior that I want.

This is the thing that when I load that webform again (and all the subsequent times), then it í "Blíss "The character appears in the server-side as Ã-. As is the key of the unit, I am trying to select a server-side database access script, it does not work because it works on 1 webform load.

I tried query string on client-side and encoding it on server-side , in this manner Using some:

client-side (javascript):

  var encodedperm = encoded printer (selected value); / * Call the handler / var url = "MyHandler.ashx? Param =" + encoded paragraph;  

server-side (ASP.NET, C #):

  string-encoded paras = reference. request. JQuery String ["Ultimate"]; String Value = HttpUtility.UrlDecode (EncodedPerm, Encoding.ASCII);  

... but I had no luck with it and the problem still remains any help?

After a few more searches, I came to know that server-side code Refinement is the deal:

I had to replace the .hx handler to parse the original parameter captured with query string and convert it to UTF-8. Here's how to create it:

// Value with the original parameter string keyring with the original parent parameter = reference. request. JQuery String ["Ultimate"]; // Query String Parameter String param = Encoding. UTF8.GetString (encoding .Get encoding ("ISO 885 9-1"), right perced value. GetBytes (paramQs));

Happy coding, people! :)


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -