473,657 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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********@hotm ail.com
http://www.nathansokalski.com/
Feb 27 '06 #1
3 1348
"Nathan Sokalski" <nj********@hot mail.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******** ******@TK2MSFTN GP10.phx.gbl...
"Nathan Sokalski" <nj********@hot mail.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.keyC ode<=90);"
TextBox2.Attrib utes.Add("onKey Press", 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********@hotm ail.com
http://www.nathansokalski.com/

"Bruce Barker" <br************ ******@safeco.c om> wrote in message
news:eB******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP10.phx.gbl...
"Nathan Sokalski" <nj********@hot mail.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
2298
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 need to: 1. Click a submit button on an asp page, calling another page that saves the contents of that form to a database and then displays
6
23743
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 in advance. Sergio Otoya.
2
17633
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 all the files in the directory and select the one with the highest week number then display in the browser window. A brief search hasn't revealed any code to do this so I just want to know if it is possible and what the function names are that...
9
4507
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 another frame using document.write. My problem is that since chat screen can be obscured by other applications/windows, I have no way of informing users that new messages have arrived other than popping the window to the top using window.focus....
12
1952
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 preset form options when the input type is a radio button, or dropdown list. The same method does not seem to work with input fields. Anyone know of such a comprehensive site?
11
14878
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, Srinivas
6
2628
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 buttons submit & cancle .
6
12071
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 link.actually i 'm using link button control to diplay the hyperlinks.i cant use java script "window.open()".i need some server side code behind the linkbutton,if any one knows plz rply soon.
2
3187
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 giving me error. typedef class x { }X;
3
7355
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 apps: MS Excel What I need to do: From a web page using javascript, I open a new Excel application and sheet, populate some information into it. After it is populated with some information, I need to run the "Solver..." option on the data in the...
0
8382
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7311
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1600
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.