473,563 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Counterpart of Javascript decodeURI()

Han
Hello

I am passing string from dotnet to javascript. ", ', newline characters, and
something. So I am using httputility.url Encode() 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.url Encode() withinn XSL extension functions. I think that's not
related with my problem.

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

I am passing string from dotnet to javascript. ", ', newline characters, and
something. So I am using httputility.url Encode() 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.Url Encode method in Javascript is the
decodeURICompon ent 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.Url Encode 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.url Encode() 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.url Encode() 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******** ******@TK2MSFTN GP06.phx.gbl...
Hello

I am passing string from dotnet to javascript. ", ', newline characters,
and something. So I am using httputility.url Encode() 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.url Encode() 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
1814
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
12862
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 variable when the city Coeur d'Alene was read. It appears that javascript is intrepreting the quote to end after d'. I've tried reversing the quotes...
1
2577
by: Niklas | last post by:
H What is Java Webstart counterpart in .NET Regard /Niklas
9
4408
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 to try out, test it only to find it only works in IE. at school, we want to test a number of javascripts, preferably compatible with *all*...
0
1141
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 in C#??? What is the right way to solve this problem? ;o) Best Regards Thomas
6
30371
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
2768
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 the redirect. Once the information has been sent via the redirect this will happen: One of the frames will pick up the sent information and...
2
1894
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, opening it in another window. That works well, but when I call the function again to write the next picture, document.write puts it in it's own...
1
3137
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: document.frame01.scroll(x,y) or possibly document.getElementById('frame01').scroll(x,y)
0
7658
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7877
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7631
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7943
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
912
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.