473,388 Members | 1,256 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,388 software developers and data experts.

Using the && operator in generated JavaScript

I have a VB.NET function that I am using in an ASP.NET page. The code
creates a String, which contains && (the JavaScript Logical AND operator)
and is used as part of the JavaScript sent to the browser. However, ASP.NET
is converting this to & even though it is intended to be part of the
JavaScript. This is causing my JavaScript not to work correctly. How can I
prevent ASP.NET from doing this substitution? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Feb 27 '06 #1
3 1230
"Nathan Sokalski" <nj********@hotmail.com> schrieb:
I have a VB.NET function that I am using in an ASP.NET page. The code
creates a String, which contains && (the JavaScript Logical AND operator)
and is used as part of the JavaScript sent to the browser. However, ASP.NET
is converting this to &amp; even though it is intended to be part of the
JavaScript. This is causing my JavaScript not to work correctly. How can I
prevent ASP.NET from doing this substitution? Thanks.


I assume this is necessary when using JavaScript in an XHTML page. You
could try to use '<![CDATA[<Your JavaScript code>]]>' to surround the script
and then use unencoded entities in the script.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 27 '06 #2
IE not being html 4.0 compliant does not support cdata's in script blocks,
so you have to embed them in javascript comments. (you should also add the
standard html comment inside the script block)

<html>
<body>
<script>
<!--
// <![CDATA[
if (true && true) document.write("hello world");
//]]
-->
</script>
</body>
</html>

-- bruce (sqlwork.com)
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
"Nathan Sokalski" <nj********@hotmail.com> schrieb:
I have a VB.NET function that I am using in an ASP.NET page. The code
creates a String, which contains && (the JavaScript Logical AND operator)
and is used as part of the JavaScript sent to the browser. However,
ASP.NET is converting this to &amp; even though it is intended to be part
of the JavaScript. This is causing my JavaScript not to work correctly.
How can I prevent ASP.NET from doing this substitution? Thanks.


I assume this is necessary when using JavaScript in an XHTML page. You
could try to use '<![CDATA[<Your JavaScript code>]]>' to surround the
script and then use unencoded entities in the script.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Feb 28 '06 #3
I am assuming that would work if I were putting the script code between
SCRIPT tags, but I am using my script in an event handler which I am adding
using the Attributes.Add() method, such as in the following:

Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"
TextBox2.Attributes.Add("onKeyPress", jscode)

This means that my code must be a String (the second parameter of the Add
method). I basically just want this part of the code to be output literally,
without trying to "interpret" anything, which it seems to be doing with the
&'s (but amazingly not to the > or <). I have never really tried fooling
aroung with the PreRender event, but putting it in that event make a
difference?
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Bruce Barker" <br******************@safeco.com> wrote in message
news:eB**************@TK2MSFTNGP12.phx.gbl...
IE not being html 4.0 compliant does not support cdata's in script blocks,
so you have to embed them in javascript comments. (you should also add the
standard html comment inside the script block)

<html>
<body>
<script>
<!--
// <![CDATA[
if (true && true) document.write("hello world");
//]]
-->
</script>
</body>
</html>

-- bruce (sqlwork.com)
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uj**************@TK2MSFTNGP10.phx.gbl...
"Nathan Sokalski" <nj********@hotmail.com> schrieb:
I have a VB.NET function that I am using in an ASP.NET page. The code
creates a String, which contains && (the JavaScript Logical AND operator)
and is used as part of the JavaScript sent to the browser. However,
ASP.NET is converting this to &amp; even though it is intended to be part
of the JavaScript. This is causing my JavaScript not to work correctly.
How can I prevent ASP.NET from doing this substitution? Thanks.


I assume this is necessary when using JavaScript in an XHTML page. You
could try to use '<![CDATA[<Your JavaScript code>]]>' to surround the
script and then use unencoded entities in the script.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Feb 28 '06 #4

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

Similar topics

3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
6
by: Sergio Otoya | last post by:
Hi all, Is there any way of copying a file using javascript, not using the Filesystemobject (ActiveX). I need this to run in Windows and MACS. Any help would be greatly appreciated. Thanks...
2
by: Dean | last post by:
Hi I've got a question relating to using Javascript on an Intranet. I have a directory with a list of files in the format week36.xls, week37.xls and I want to write a script that will scan...
9
by: CW | last post by:
I wrote an HTML based chat application. The front end is built entirely on HTML + javascript. Essentially, I have a hidden frame that's refreshed frequently and any new messages are displayed in...
12
by: daniel kaplan | last post by:
Hi All, Been learning Javascript (via google) to create forms with pre-set values. As seen below. My problem I have found is this: I can't seem to figure out (or find so far via google) how to...
11
by: srinivas | last post by:
Hi all, I have one requirement.Is there any way to create a line graph using javascript.If it is please send me the sample code.But the thing is it should work in all browsers. Thanks,...
6
by: prash.marne | last post by:
hi all , this is a very simple problem but i need some help, My situation is : i have a form which opens in a pop-up window , in which user will insert his email-id & name , there are two...
6
by: bushi | last post by:
hi everyone! i have diplayed my hyperlinks in a iframe.when i redirect to next page.the next page also open in the same frame,but i want to open a new browser window,when i click on the...
2
by: Bharath | last post by:
Hello All, Can you please let me know if we can do pointer arthrmetic using operator overloading? If not, can you please explain why it's not supported by compiler? I tried below e.g. which was...
3
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.