473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Counterpart of Javascript decodeURI()

Han
Hello

I am passing string from dotnet to javascript. ", ', newline characters, and
something. So I am using httputility.urlEncode() to make it neat.
Now a JS function accepts the encoded string and decode using decodeURI().
But still there are unsolved characters and some +, %, and hex numbers. What
is exact dotnet counterpart of JS decodeURI()?

I am not sure this matters. I am not using typical asp.net + JS. I am using
httputility.urlEncode() withinn XSL extension functions. I think that's not
related with my problem.

Thanks for your reading
Jul 25 '07 #1
4 7172
Han wrote:
Hello

I am passing string from dotnet to javascript. ", ', newline characters, and
something. So I am using httputility.urlEncode() to make it neat.
Now a JS function accepts the encoded string and decode using decodeURI().
But still there are unsolved characters and some +, %, and hex numbers. What
is exact dotnet counterpart of JS decodeURI()?
As far as I know, there is no counterpart in .NET for the Javascript
function decodeURI.

The counterpart of the HttpUtility.UrlEncode method in Javascript is the
decodeURIComponent function.

--
Göran Andersson
_____
http://www.guffa.com
Jul 25 '07 #2
there are generic problems with using url encode logic for this. url
encode is designed to encode a url, which has some ambiguous characters.
in a url no spaces are allowed, so a "+" is used instead. this means
there is no way in an encoded url to deteremine if a "+" is a plus or a
space. to solve this javascript has encodeURI and decodeURI which
handles this (spaces become %20, plus is left alone).

HttpUtility.UrlEncode converts spaces to "+" and "+" to %2b, so its not
compatible with decodeURI. you will have to write your own encoder.

the other approach is to store the data in a hidden field rather than a
javascript variable, then no decoding is required in javascript, and
HtmlEncode works correctly.

-- bruce (sqlwork.com)
Han wrote:
Hello

I am passing string from dotnet to javascript. ", ', newline characters, and
something. So I am using httputility.urlEncode() to make it neat.
Now a JS function accepts the encoded string and decode using decodeURI().
But still there are unsolved characters and some +, %, and hex numbers. What
is exact dotnet counterpart of JS decodeURI()?

I am not sure this matters. I am not using typical asp.net + JS. I am using
httputility.urlEncode() withinn XSL extension functions. I think that's not
related with my problem.

Thanks for your reading

Jul 25 '07 #3
Han
Thanks G?an Andersson and bruce barker.

No way to pass arbitrary string dynamically, even to hidden field, I
redesigned the whole process.

"Han" <hp****@kornet.net.koreawrote in message
news:Os**************@TK2MSFTNGP06.phx.gbl...
Hello

I am passing string from dotnet to javascript. ", ', newline characters,
and something. So I am using httputility.urlEncode() to make it neat.
Now a JS function accepts the encoded string and decode using decodeURI().
But still there are unsolved characters and some +, %, and hex numbers.
What is exact dotnet counterpart of JS decodeURI()?

I am not sure this matters. I am not using typical asp.net + JS. I am
using httputility.urlEncode() withinn XSL extension functions. I think
that's not related with my problem.

Thanks for your reading

Jul 26 '07 #4
Han wrote:
Thanks G?an Andersson and bruce barker.

No way to pass arbitrary string dynamically, even to hidden field, I
redesigned the whole process.
If you put the value in an asp:HiddenField, you don't have to encode it
at all. The control will html-encode the value properly.

When you read the value on the client side, you don't have to decode it
either. The browser has done that.

--
Göran Andersson
_____
http://www.guffa.com
Jul 26 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jinming Xu | last post by:
Hi Folks, Could any of you please teach me what's the counterpart of Python None in C++ side? Since I need to manipulate a Python None in C++. Thanks a lot, Jinming Xu ...
3
by: Jeanne | last post by:
I am working on a cgi script that is suppose to pop-up a javascript box from the following perl variables:$TodayDate, $LinkCity, $LinkState. I recently encountered a problem with the $LinkCity...
1
by: Niklas | last post by:
H What is Java Webstart counterpart in .NET Regard /Niklas
9
by: bert76 | last post by:
can anyone suggest a couple of websites providing *compatible* javascript? of course there is http://javascript.internet.com/ http://javascriptkit.com/ and the likes, but time and again you have...
0
by: Thomas | last post by:
Hello everybody, I have a C++ application which gives a DLL 2 handles from cevent objects. Now I need to use this DLL with C#, but I don't know how to create a counterpart of the cevent object...
6
by: Andrew | last post by:
Hi, friends, In VB, there is a vbCrLf for a new line. What is the counterpart in C#? Thanks.
5
by: Dan | last post by:
Hi, Is there a way to send information via javascript by redirecting to a page that contains frames? The information that will have to be sent will be the page name of the original page before...
2
by: Ryan | last post by:
Howdy. I'm writing a photo slideshow in javascript (using js to make it more user-universal). I have the functions set up to get a photo thumb from an array and link it to its larger counterpart,...
1
by: John L. | last post by:
How do I invoke the scroll() method of a window object for a scrollable IFRAME element in an HTML document? I am using IE 7.0, and I thought the following would work: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.