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

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:CheckBoxList Runat="server" id="CheckBoxList1">
<asp:ListItem Value="a">Checked a</asp:ListItem>
<asp:ListItem Value="b">Checked b</asp:ListItem>
<asp:ListItem Value="c">Checked c</asp:ListItem>
<asp:ListItem Value="d">Checked d</asp:ListItem>
<asp:ListItem Value="e">Checked e</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<div><b><i>Action 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.Attributes.Add("onclick", "javascript:form1.notes.value =
'this is a test'")

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
3 6369
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:CheckBoxList Runat="server" id="CheckBoxList1">
<asp:ListItem Value="a">Checked a</asp:ListItem>
<asp:ListItem Value="b">Checked b</asp:ListItem>
<asp:ListItem Value="c">Checked c</asp:ListItem>
<asp:ListItem Value="d">Checked d</asp:ListItem>
<asp:ListItem Value="e">Checked e</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>
<div><b><i>Action 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...Does 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...Does 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
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...
0
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...
3
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...
10
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...
3
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...
2
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...
4
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...
4
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...
7
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,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.