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
ThunderMusic 7 2200
ThunderMusic wrote: 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
ThunderMusic
If you want to add javascript in this way you'll need to do it before
the controls are rendered to the page i.e. before page load. Try to
using Control.Attribs.Add in the soonest possible event; usually
onInitEvent or onItemDataBound.
--
Rob Schieber
Thanks for the help. Indeed, it worked in the OnInit method of the page, but
I changed the way I'm doing it, so now the OnClick event is managed directly
from the form, so everything clickable is readonly (it is a print preview
form) so I only have to manage the OnClick once.
Thanks a lot
ThunderMusic
"Rob Schieber" <sc******@hotmail.com> wrote in message
news:eg**************@TK2MSFTNGP14.phx.gbl... ThunderMusic wrote: 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
ThunderMusic
If you want to add javascript in this way you'll need to do it before the controls are rendered to the page i.e. before page load. Try to using Control.Attribs.Add in the soonest possible event; usually onInitEvent or onItemDataBound.
-- Rob Schieber
The CheckBoxList is giving me a hard time too if I may jump into this news
article. The checkboxes have colored backgrounds I can't figure out how to
get rid of and I can't apply padding or margins to the text noting this is a
piece of cake when working with HTML but this control seems to be a
composite control and I can't figure out how to access the properties I
need. Any idea how I might clean it up?
<%= Clinton Gallagher
"ThunderMusic" <NO****@NoSPAM.Info> wrote in message
news:uH**************@TK2MSFTNGP11.phx.gbl... Thanks for the help. Indeed, it worked in the OnInit method of the page, but I changed the way I'm doing it, so now the OnClick event is managed directly from the form, so everything clickable is readonly (it is a print preview form) so I only have to manage the OnClick once.
Thanks a lot
ThunderMusic
"Rob Schieber" <sc******@hotmail.com> wrote in message news:eg**************@TK2MSFTNGP14.phx.gbl... ThunderMusic wrote: 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
ThunderMusic
If you want to add javascript in this way you'll need to do it before the controls are rendered to the page i.e. before page load. Try to using Control.Attribs.Add in the soonest possible event; usually onInitEvent or onItemDataBound.
-- Rob Schieber
my guess would be to add your things in the OnInit event of the page... it
worked for me, maybe it will for you too...
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le
message de news: %2***************@TK2MSFTNGP11.phx.gbl... The CheckBoxList is giving me a hard time too if I may jump into this news article. The checkboxes have colored backgrounds I can't figure out how to get rid of and I can't apply padding or margins to the text noting this is a piece of cake when working with HTML but this control seems to be a composite control and I can't figure out how to access the properties I need. Any idea how I might clean it up?
<%= Clinton Gallagher
"ThunderMusic" <NO****@NoSPAM.Info> wrote in message news:uH**************@TK2MSFTNGP11.phx.gbl... Thanks for the help. Indeed, it worked in the OnInit method of the page, but I changed the way I'm doing it, so now the OnClick event is managed directly from the form, so everything clickable is readonly (it is a print preview form) so I only have to manage the OnClick once.
Thanks a lot
ThunderMusic
"Rob Schieber" <sc******@hotmail.com> wrote in message news:eg**************@TK2MSFTNGP14.phx.gbl... ThunderMusic wrote: 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
ThunderMusic
If you want to add javascript in this way you'll need to do it before the controls are rendered to the page i.e. before page load. Try to using Control.Attribs.Add in the soonest possible event; usually onInitEvent or onItemDataBound.
-- Rob Schieber
Hmmm. I was concerned that I would have to write code to work around a poor
implementation of these "list" controls.
<%= Clinton Gallagher
"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
news:eQ*************@TK2MSFTNGP12.phx.gbl... my guess would be to add your things in the OnInit event of the page... it worked for me, maybe it will for you too...
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le message de news: %2***************@TK2MSFTNGP11.phx.gbl... The CheckBoxList is giving me a hard time too if I may jump into this news article. The checkboxes have colored backgrounds I can't figure out how to get rid of and I can't apply padding or margins to the text noting this is a piece of cake when working with HTML but this control seems to be a composite control and I can't figure out how to access the properties I need. Any idea how I might clean it up?
<%= Clinton Gallagher
"ThunderMusic" <NO****@NoSPAM.Info> wrote in message news:uH**************@TK2MSFTNGP11.phx.gbl... Thanks for the help. Indeed, it worked in the OnInit method of the page, but I changed the way I'm doing it, so now the OnClick event is managed directly from the form, so everything clickable is readonly (it is a print preview form) so I only have to manage the OnClick once.
Thanks a lot
ThunderMusic
"Rob Schieber" <sc******@hotmail.com> wrote in message news:eg**************@TK2MSFTNGP14.phx.gbl... ThunderMusic wrote: > 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 > > ThunderMusic
If you want to add javascript in this way you'll need to do it before the controls are rendered to the page i.e. before page load. Try to using Control.Attribs.Add in the soonest possible event; usually onInitEvent or onItemDataBound.
-- Rob Schieber
hi,
yes, but we're talking about 1line of code
YourChkBoxList.Attributes.Add("Style", "Margin: 5px; background-color:
#FFFFFF")
and that's about it. if it's not exactly it, it is quite similar... As I
said in an earlier post, I don't use it anymore because I found an easier
solution to my problem, but I think it's the way I was doing it. if it's not
working, try going trought all the controls (child controls of your
chkboxlist) and add the attribute, but in the OnInit, I don't think they
will be created, so that's why you can add it directly to the chkboxlist...
and as for style, you could try to add it directly in the aspx code because
it's not likely to change... I didn't try it, but it could work... it was
not suited for my problem though as each chkbox had something
different......
I hope it helps
ThunderMusic
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le
message de news: eL**************@tk2msftngp13.phx.gbl... Hmmm. I was concerned that I would have to write code to work around a poor implementation of these "list" controls.
<%= Clinton Gallagher "ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message news:eQ*************@TK2MSFTNGP12.phx.gbl... my guess would be to add your things in the OnInit event of the page... it worked for me, maybe it will for you too...
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le message de news: %2***************@TK2MSFTNGP11.phx.gbl... The CheckBoxList is giving me a hard time too if I may jump into this news article. The checkboxes have colored backgrounds I can't figure out how to get rid of and I can't apply padding or margins to the text noting this is a piece of cake when working with HTML but this control seems to be a composite control and I can't figure out how to access the properties I need. Any idea how I might clean it up?
<%= Clinton Gallagher
"ThunderMusic" <NO****@NoSPAM.Info> wrote in message news:uH**************@TK2MSFTNGP11.phx.gbl... Thanks for the help. Indeed, it worked in the OnInit method of the page, but I changed the way I'm doing it, so now the OnClick event is managed directly from the form, so everything clickable is readonly (it is a print preview form) so I only have to manage the OnClick once.
Thanks a lot
ThunderMusic
"Rob Schieber" <sc******@hotmail.com> wrote in message news:eg**************@TK2MSFTNGP14.phx.gbl... > ThunderMusic wrote: >> 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 >> >> ThunderMusic > > If you want to add javascript in this way you'll need to do it before > the controls are rendered to the page i.e. before page load. Try to > using Control.Attribs.Add in the soonest possible event; usually > onInitEvent or onItemDataBound. > > -- > Rob Schieber
Thanks for your comments. Accessing the child controls (Labels) of the
CheckBoxList is going to be a bit tricky I think as the Labels emitted by a
ListItem are already being rendered using a <span>. I am also using the
CheckBoxList as a child of a Wizard in 2.0 Master Pages which adds a bit of
spaghetti to the bowl. I better just get busy...
<%= Clinton Gallagher
"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl... hi, yes, but we're talking about 1line of code
YourChkBoxList.Attributes.Add("Style", "Margin: 5px; background-color: #FFFFFF")
and that's about it. if it's not exactly it, it is quite similar... As I said in an earlier post, I don't use it anymore because I found an easier solution to my problem, but I think it's the way I was doing it. if it's not working, try going trought all the controls (child controls of your chkboxlist) and add the attribute, but in the OnInit, I don't think they will be created, so that's why you can add it directly to the chkboxlist... and as for style, you could try to add it directly in the aspx code because it's not likely to change... I didn't try it, but it could work... it was not suited for my problem though as each chkbox had something different......
I hope it helps
ThunderMusic
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le message de news: eL**************@tk2msftngp13.phx.gbl... Hmmm. I was concerned that I would have to write code to work around a poor implementation of these "list" controls.
<%= Clinton Gallagher "ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message news:eQ*************@TK2MSFTNGP12.phx.gbl... my guess would be to add your things in the OnInit event of the page... it worked for me, maybe it will for you too...
"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> a écrit dans le message de news: %2***************@TK2MSFTNGP11.phx.gbl... The CheckBoxList is giving me a hard time too if I may jump into this news article. The checkboxes have colored backgrounds I can't figure out how to get rid of and I can't apply padding or margins to the text noting this is a piece of cake when working with HTML but this control seems to be a composite control and I can't figure out how to access the properties I need. Any idea how I might clean it up?
<%= Clinton Gallagher
"ThunderMusic" <NO****@NoSPAM.Info> wrote in message news:uH**************@TK2MSFTNGP11.phx.gbl... > Thanks for the help. Indeed, it worked in the OnInit method of the > page, but I changed the way I'm doing it, so now the OnClick event is > managed directly from the form, so everything clickable is readonly > (it is a print preview form) so I only have to manage the OnClick > once. > > Thanks a lot > > ThunderMusic > > "Rob Schieber" <sc******@hotmail.com> wrote in message > news:eg**************@TK2MSFTNGP14.phx.gbl... >> ThunderMusic wrote: >>> 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 >>> >>> ThunderMusic >> >> If you want to add javascript in this way you'll need to do it before >> the controls are rendered to the page i.e. before page load. Try to >> using Control.Attribs.Add in the soonest possible event; usually >> onInitEvent or onItemDataBound. >> >> -- >> Rob Schieber > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
by: JD |
last post by:
Hello,
I have a problem with checkboxlist inside Repeater (in ASP.NET page).
I am able to create Checkboxlist and bind it (inside Repeater_ItemBound -
including setting checked/unchecked)....
|
by: Ryan Scully |
last post by:
Hello I have problem with determining exactly what CheckBoxList element is selected using JavaScript code. When I databind to the checkboxlist it renders it on the page and instead of giving each...
|
by: Dune |
last post by:
Hi,
Is there anyway to get the datavaluefield from a databound checkboxlist
using javascript?
If not, is there any way to associate a custom attribute with the databound
checkboxlist items so...
|
by: Stimp |
last post by:
I have a checkboxlist (chkMyList) which is created from a (name, value)
pair from a database table.
I have a read-only textbox which will be used to hold a total of
all the numerical values of...
|
by: webmaster |
last post by:
Hi all,
I'm tearing my hair out with this one.
I have successfully implemented by own RadioButtonList in order to
provide additional functionality and a DIV rather than TABLE-based
layout in...
|
by: haresh.amis |
last post by:
hello to all,
I m using .net 2.0 and i face a problem that is as under
Well I have a checkboxlist which i bound in .cs page
now I want to count that how many checkboxes ate checked ( In...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
| |