msiedle
asked on
VB.NET version of CheckBoxList Select All Functionality
Hi all
I have a checkboxlist of items ...and I want to be able to add a 'select all' checkbox above it that works with javascript on the client side ...
I have tried to do this by adding a checkbox and doing the following, but I get an error in the codebehind saying "Operator + is not defined for types String and CheckBoxList" ...any ideas what I'm doing wrong? ..or if anyone has some existing code they use to accomplish the same task client-side?
presentation ASP.NET
==============
<asp:CheckBox ID="chk_select_all" Runat="server"></asp:Check Box>
<asp:CheckBoxList ID="cbl_tables" Runat="server" AutoPostBack=true>
code behind VB.NET
=============
chk_select_all.Attributes. Add("oncli ck", "CheckAll('" + cbl_tables + "_',checked);")
The CheckAll javascript is as follows ...added to ASP.NET form:
========================== ========== =====
<script>
function CheckAll(pattern, bCheck)
{
var inps = document.getElementsByTagN ame("INPUT ");
var i;
for(i=0;i<inps.length;i++)
{
if(pattern =='' || inps[i].id.indexOf(pattern ) >=0)
if(inps[i].onclick!=Return False)
inps[i].checked = bCheck;
}
return;
}
</script>
Cheers,
Mark
I have a checkboxlist of items ...and I want to be able to add a 'select all' checkbox above it that works with javascript on the client side ...
I have tried to do this by adding a checkbox and doing the following, but I get an error in the codebehind saying "Operator + is not defined for types String and CheckBoxList" ...any ideas what I'm doing wrong? ..or if anyone has some existing code they use to accomplish the same task client-side?
presentation ASP.NET
==============
<asp:CheckBox ID="chk_select_all" Runat="server"></asp:Check
<asp:CheckBoxList ID="cbl_tables" Runat="server" AutoPostBack=true>
code behind VB.NET
=============
chk_select_all.Attributes.
The CheckAll javascript is as follows ...added to ASP.NET form:
==========================
<script>
function CheckAll(pattern, bCheck)
{
var inps = document.getElementsByTagN
var i;
for(i=0;i<inps.length;i++)
{
if(pattern =='' || inps[i].id.indexOf(pattern
if(inps[i].onclick!=Return
inps[i].checked = bCheck;
}
return;
}
</script>
Cheers,
Mark
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Mark