473,513 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Issue with Control.Attributes Property when adding Javascript

Sorry to bother everyone with this question, but the answer to this the
question is difficult to search for. I want to add javascript to an
HtmlInputButton control attribute. A portion of the javascript goes
something like this:

if( x < y && x != y )
{
// do something
}

It is rendered as follows:

if( x &lt; y &amp;&amp; x != y )
{
// do something
}

How do I preserve the literal "<" and "&"?

Thanks a lot!

Oct 11 '06 #1
6 1600
Are there alternate methods for comparisons?

For example:
bool greaterThan( x, y );
bool lessThanEqualTo( x, y );

Oct 11 '06 #2
Ch***********@gmail.com wrote:
I want to add javascript to an HtmlInputButton control attribute ...
How do I preserve the literal "<" and "&"?
You don't. When you call Attributes.Add(), ASP.NET automatically
converts them to their HTML entity references, which is correct. Are
you finding that this method doesn't work correctly?

Tim

Oct 11 '06 #3
To clarify, the output you are getting is the correct way to output
those characters in an attribute. Why do you need to change this
behaviour? Do you find that the script fails to execute?

Tim

Oct 11 '06 #4
Well I suppose the method is working "correctly", but from what I can
tell it is limiting my ability to insert javascript into the attribute
value. I need to do the comparison somehow. I'd prefer to keep the
javascript in that particular button's element.

Can you think of a good work-around? Is the Render method going to be
my best bet for getting the results I want?

Oct 11 '06 #5
Ch***********@gmail.com wrote:
I want to add javascript to an HtmlInputButton control attribute ...
How do I preserve the literal "<" and "&"?
You don't. When you call Attributes.Add(), ASP.NET automatically
converts them to their HTML entity references, which is correct. Are
you finding that this method doesn't work correctly?

Tim

Oct 11 '06 #6
In response to your prior post for clarification:

Yes, the script does not execute due to a syntax error. When I view the
source I see something like:

if( x &lt; y &amp;&amp; y &gt; x )
{

}

The above is definitely not correct syntax. What I need is:

if( x < y && y x )
{

}

Oct 11 '06 #7

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

Similar topics

9
5472
by: James Geurts | last post by:
Hey all... I posted this in the vs.net ide group too, but people are not answering, so I figured that it might be more appropriate here. I'm not sure if I'm adding a designer to my code properly. ...
2
13132
by: Rob Richardson | last post by:
Greetings! I just developed a little control I've wanted for ages. It links a textbox and a label into a single control. At first, I gave it a property named LabelText and another named...
3
3595
by: Shevek | last post by:
Hi All, Hope someone can help! I am building an Event Calendar app based around the Calendar WebControl which builds an SQL string based on the SelectedDates property which is passed to...
6
14674
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm...
1
11855
by: ANDRES BECERRA | last post by:
Herfried K. Wagner was kind enough to point me to the PropertyGrid control http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformspropertygridclasstopic.asp I have found a few...
3
6718
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
3
4022
by: Brad | last post by:
The first text on my form is a numeric field. I have a javascript that runs on this field for onkeyup (validate the key strokes and modifies fields on the screen) but when I do this and have the...
6
1352
by: RSH | last post by:
I have a situation where I am successfully adding an Onload to the Body tag from the codebehind from a page using the following code: Protected WithEvents body1 As...
0
260
by: ChrisMiddle10 | last post by:
Sorry to bother everyone with this question, but the answer to this the question is difficult to search for. I want to add javascript to an HtmlInputButton control attribute. A portion of the...
0
7265
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
7388
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
7547
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...
1
7114
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
5693
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,...
0
4751
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...
0
3240
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...
0
3230
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.