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

adding attribute to checkbox

hello.

I am trying to add an attribute on the checkbox.

In my C# code,

chkText.Attributes.Add("onChange", "window.alert('hello');return false");

But the result is like below on the web browser,

<span onChange="window.alert('bk');return false"><input id="chkTest"
type="checkbox" name="chkTest" /><label for="chkTest">test</label></span>

Anyone know how to add that onChange event on the input tag???

Thanx in advance
Nov 17 '05 #1
1 4206
"BK Kim" <bk***@destinationrx.com> wrote in message
news:eJ**************@TK2MSFTNGP11.phx.gbl...
hello.

I am trying to add an attribute on the checkbox.

In my C# code,

chkText.Attributes.Add("onChange", "window.alert('hello');return false");

But the result is like below on the web browser,

<span onChange="window.alert('bk');return false"><input id="chkTest"
type="checkbox" name="chkTest" /><label for="chkTest">test</label></span>

Anyone know how to add that onChange event on the input tag???


You can't. The CheckBox control is the span, not the input tag.

You'll have to use <input type="checkbox" runat="server"> instead.
--
John
Nov 17 '05 #2

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

Similar topics

4
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. ...
32
by: Ed Jay | last post by:
A complete js newbie is asking this question: I have a form comprised of several questions, each answered with a radio button. I'd like to use onClick to bring up additional text at the end of...
2
by: Stephen Lambie | last post by:
Hi, I want to develop a custom checkbox. I want to use the existing checkbox in a custom control where I use the disabled state as a third state. I need to be able to detect mouse or click...
19
by: Sjaakie Helderhorst | last post by:
Hello, I need to add a Javascript event (onClick) to a servercontrol (asp:checkbox). Checkbox is named 'cbDoMail'. Assumed that 'cbDoMail.Attributes.Add("onClick", "doJavascriptThing()") would do...
1
by: darkpeace | last post by:
Okay i'm at my wits end. I've tried every which way to add a simple onClick even to checkbox items in my code behind : example: Protected WithEvents chkSample As...
3
by: vikram | last post by:
How can i add a user define attribute to each checkbox item in a checkbox list control. I want to add a attribute "Tag". Is it possible
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
0
by: Jaime Stuardo | last post by:
Hi all... I have the following curious problem, I have a GridView that I bind after I press a button in the web form. That grid has a template column, which contains a checkbox (in the header...
3
by: 张韡武 | last post by:
Hello. I am a newbie trying to get my first XLST script working. I already know how to do this: Source XML: <category id="a0104"> <name>Oil and Gas</name> </category> XSLT: <xsl:for-each...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
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...
0
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...

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.