473,788 Members | 2,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to rig a Checkboxlist Onclick event?

Roy
The title is self-explanatory, but I'll show you all what I've done thus
far.

Here's the aspx side of things(trimmed, of course):
<form name="form1" id="Form1" method="post" runat="server">
<table width="100%">
<tr>
<td>
<asp:CheckBoxLi st Runat="server" id="CheckBoxLis t1">
<asp:ListItem Value="a">Check ed a</asp:ListItem>
<asp:ListItem Value="b">Check ed b</asp:ListItem>
<asp:ListItem Value="c">Check ed c</asp:ListItem>
<asp:ListItem Value="d">Check ed d</asp:ListItem>
<asp:ListItem Value="e">Check ed e</asp:ListItem>
</asp:CheckBoxLis t>
</td>
</tr>
<tr>
<td>
<div><b><i>Acti on Notes</i></b></div>
</td>
</tr>
<tr>
<td>
<textarea id="notes" rows="3" cols="25" runat="server"
NAME="notes"></textarea>
</td>
</tr>
</table>

I tried to stick the javascript below into the page_load event, but it's
just not working. :( Any clues? Am I on the right track? Thanks!

CheckBoxList1.A ttributes.Add(" onclick", "javascript:for m1.notes.value =
'this is a test'")

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
3 6409
first off, play with the clientside code, with an all clientside control, and
get that working. After that, THEN, try to add it to the attributes. Its not
really and ASP.Net issue, it's a javascript one I think.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Roy" wrote:
The title is self-explanatory, but I'll show you all what I've done thus
far.

Here's the aspx side of things(trimmed, of course):
<form name="form1" id="Form1" method="post" runat="server">
<table width="100%">
<tr>
<td>
<asp:CheckBoxLi st Runat="server" id="CheckBoxLis t1">
<asp:ListItem Value="a">Check ed a</asp:ListItem>
<asp:ListItem Value="b">Check ed b</asp:ListItem>
<asp:ListItem Value="c">Check ed c</asp:ListItem>
<asp:ListItem Value="d">Check ed d</asp:ListItem>
<asp:ListItem Value="e">Check ed e</asp:ListItem>
</asp:CheckBoxLis t>
</td>
</tr>
<tr>
<td>
<div><b><i>Acti on Notes</i></b></div>
</td>
</tr>
<tr>
<td>
<textarea id="notes" rows="3" cols="25" runat="server"
NAME="notes">

Nov 19 '05 #2
Roy
Thanks for the reply Curt, but I'm actually beginning to suspect that
one *cannot* generate an onclick event for a checkboxlist
whatsoever...Do es anyone have any insight on this?

In this scenario, what would you recommend as an alternative plan?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3
Well, I just did this
myCheckBoxList. Attributes.Add( "onclick", "alert('test')" )

and it works just fine.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"Roy" wrote:
Thanks for the reply Curt, but I'm actually beginning to suspect that
one *cannot* generate an onclick event for a checkboxlist
whatsoever...Do es anyone have any insight on this?

In this scenario, what would you recommend as an alternative plan?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #4

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

Similar topics

2
1594
by: sql | last post by:
Hi all, I am using a CheckBoxList control on my aspx page that I bind to an array at runtime. After I databind it, I check two of the items in the CheckBoxList controls. Now I also need to disable these two items so that users can't uncheck them. But I don't know how to disable individual items. Can you please help me achieving this(preferably at runtime)? Thanks in advance.
0
7949
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all before commercialization took over that was the beauty of the Internet! I've create a checkboxlist validator control...something MS should have done originally in my opinion, but nonetheless here it is. It's a C# control, sort of IE specific. ...
3
5456
by: Robin Day | last post by:
I run some code on the changed event of checkbox lists. Its quite simple, nothing more than showing / hiding some other parts of the page. Using Autopostback and Server side code works fine, but is far too slow, especially if the users are on modems. I need to quite simply, add some java code to the onclick event of the input tags of a checkboxlist. However... Attributes.Add adds the onclick attribute and code to the outlying table that...
10
1963
by: suzy | last post by:
i have generated a list of checkboxes (at runtime) using the checkboxlist control. i want to add an onclick event onto each checkbox so i can perform a count of how many items have been selected every time a checkbox is clicked. how can i do this? remember, the checkboxes are generated at runtime. thanks
3
2922
by: I am Sam | last post by:
I keep getting the following error message when I try to iterate through a CheckBoxList control: Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance...
2
2086
by: Nemo | last post by:
Hi. I Have a CheckBoxList and I would like the add the onclick attribute. But when I add the attribute only the first one in my list get the onclick attribute. Here is my code. protected CheckBoxList myCheckBoxList;
4
4043
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to work:( Thanks My CheckBoxList in the DataList Below
4
6544
by: MattB | last post by:
I have a CheckBoxList that under some circumstances I want to only allow one selection, so that if you select a different item, whatever was selected before becomes un-selected. Any ideas on how to do this? Ideas, and even better, examples would be appreciated! Matt
7
2228
by: ThunderMusic | last post by:
Hi, I have a CheckBoxList and I want to add some javascript code to each CheckBox created by this CheckBoxList. I tried iterating through all items of the list, all the controls, do a FindControl, et al. with no good result. I would use the Control.Attribute.Add("OnClick", "some javascript code") Does someone know a solution? Thanks
0
9656
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
9498
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
10366
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
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
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
6750
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
5399
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.