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

Checkboxlist Clientside rather than Serverside

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 the framework creates.
Is there a way of getting this code and events into the input tags?

Any help or ideas much appreciated.

Thanks
Robin
Nov 18 '05 #1
3 5434
Have you tried using individual checkbox controls with the attributes.add
rather than a checkboxlist control?
"Robin Day" <ro*******@advorto.com> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
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 the framework creates.
Is there a way of getting this code and events into the input tags?

Any help or ideas much appreciated.

Thanks
Robin

Nov 18 '05 #2
The way the checkboxlist control works is very useful in this application.
It is deeply embedded into a number of custom webcontrols that are used in
various places on a number of systems.
I really don't want to have to produce my own version of the checkboxlist
when the only functional change I require is to add some onclick javascript.
Is it possible that there's some other way of accesseing the individual
input tags as the control renders? So I can manually add the events there?
Or possibly a way of using a custom validator that could fire the javascript
instead?

Thanks,
Robin

"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:O0**************@TK2MSFTNGP11.phx.gbl...
Have you tried using individual checkbox controls with the attributes.add
rather than a checkboxlist control?
"Robin Day" <ro*******@advorto.com> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
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 the framework creates.
Is there a way of getting this code and events into the input tags?

Any help or ideas much appreciated.

Thanks
Robin


Nov 18 '05 #3
hi Robin,
I never expected to have to put all this time just to add that onclick
attribute to every checkbox in your checkboxlist control. Actually it does
sound very simple and then gets impossible --however I did get there
eventually.

At first I assumed trying to get to the items in the checkboxList item
collection and adding the onclick attribute would work, however no
attribute is being set --just turns up blank

For i = 0 To CheckBoxList1.Items.Count - 1
CheckBoxList1.Items.Item(i).Attributes.Item("oncli ck") =
"MyFunction();"
Next

whereas if you tried to set the text property of an item in the checkboxlist
it sets :S

Private Sub CheckBoxList1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles CheckBoxList1.Load

For i = 0 To CheckBoxList1.Items.Count - 1
CheckBoxList1.Items.Item(i).text = "New value"
Next
End sub

When trying to add the onclick attribute through the controls collection of
the CheckboxList control the individual checkboxes get wrapped around span
tags with the onclick attribute i add. This is the same behaviour you get
when trying to add attributes to a checkbox control.

Unfortunately this is the behaviour of the checkbox control which you cannot
change and is useless to you because this will return a span element and not
the checkbox in itself if you tried to access the checkbox from javascript
via that onclick function you attach, however you can easily work around
this if you tried to pass "this.firstChild" element in javascript to your
function, which will return your checkbox element.

like this :

Dim c As Control
For Each c In CheckBoxList1.Controls

If TypeOf c Is CheckBox Then
CType(c, CheckBox).Attributes.Add("Onclick",
"functionClick(this.firstChild);")
End If
Next
Control output :

<table id="CheckBoxList1" border="0" style="Z-INDEX: 102; LEFT: 284px;
POSITION: absolute; TOP: 294px">
<tr>
<td><span Onclick="functionClick(this.firstChild)"><input
id="CheckBoxList1_0" type="checkbox"

name="CheckBoxList1:0" /><label for="CheckBoxList1_0">1</label></span></td>
</tr><tr>
<td><span Onclick="functionClick(this.firstChild)"><input
id="CheckBoxList1_1" type="checkbox"

name="CheckBoxList1:1" /><label for="CheckBoxList1_1">2</label></span></td>
</tr>
</table>

"Robin Day" <ro*******@advorto.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
The way the checkboxlist control works is very useful in this application.
It is deeply embedded into a number of custom webcontrols that are used in
various places on a number of systems.
I really don't want to have to produce my own version of the checkboxlist
when the only functional change I require is to add some onclick javascript. Is it possible that there's some other way of accesseing the individual
input tags as the control renders? So I can manually add the events there?
Or possibly a way of using a custom validator that could fire the javascript instead?

Thanks,
Robin

"Scott M." <s-***@BADSPAMsnet.net> wrote in message
news:O0**************@TK2MSFTNGP11.phx.gbl...
Have you tried using individual checkbox controls with the attributes.add
rather than a checkboxlist control?
"Robin Day" <ro*******@advorto.com> wrote in message
news:OA**************@tk2msftngp13.phx.gbl...
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 the framework creates.
Is there a way of getting this code and events into the input tags?

Any help or ideas much appreciated.

Thanks
Robin



Nov 18 '05 #4

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

Similar topics

3
by: Jack Black | last post by:
Using VS.Net 2k3 to build ASP.Net app with VB code-behind pages... Hi, all! I've been struggling with getting a dynamically-generated CheckBoxList generated. I've finally been able to get the...
3
by: Roy | last post by:
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">...
3
by: RFS666 | last post by:
Hello together, I tried to find out about populating an asp.net server control (a dropdownlist) from the clientside jscript, but I didn't find a solution up to now. I cannot use a html...
4
by: Hans | last post by:
Hi, I have created an extension that only runs on the serverside and not on both the client and the server side. I have to in the BeforeDeSerialize fix my dateTime so the deserialisation...
2
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...
0
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...
2
by: rishabhshrivastava | last post by:
Hi All, I am using CallBack feature in ASP.NET 2.0 and I am running into a problem with checkboxlist control. I have to find out which checkboxes are checked and get their values at...
2
by: Bart Van Hemelen | last post by:
The situation: I have a CheckBoxList cblTest, the items are disabled in cblTest_DataBound in a foreach (ListItem oItem in cblTest.Items) loop. I provide a link that calls a client-side JavaScript...
7
by: mc | last post by:
I've not been able to get a Check box to client side validated on postback. with my changes I can get it to work on the serverside ok but not on the client. I have created a new control as...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.