473,491 Members | 3,350 Online
Bytes | Software Development & Data Engineering Community
Create 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 1599
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
5466
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
3592
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
14671
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
11849
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
6710
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
4019
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
7118
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
6980
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...
0
7157
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
7192
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
6862
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
7364
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
3087
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
1397
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 ...
0
282
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...

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.