sharpnet
asked on
Error in a simple javascript call from a checkbox 'OnCheckedChange'
Morning,
I have been banging my head trying to figure out why a simple javascript call from a checkbox keeps failing. The error comes back saying : CS1026 expected ), but the syntax is correct. Below is my code. The error occurs on the second line, the asp checkbox control. Please help...
I've already tried removing the 'return' statement and modifying the syntax, but it should be fine the way it is...
Thanks,
Nick
************************** ********** ********** ********
Code:
<HeaderTemplate>
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged="javascri pt: return select_deselectAll(this.ch ecked, this.id);" runat="server"></asp:Check Box>
</HeaderTemplate>
I have been banging my head trying to figure out why a simple javascript call from a checkbox keeps failing. The error comes back saying : CS1026 expected ), but the syntax is correct. Below is my code. The error occurs on the second line, the asp checkbox control. Please help...
I've already tried removing the 'return' statement and modifying the syntax, but it should be fine the way it is...
Thanks,
Nick
**************************
Code:
<HeaderTemplate>
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged="javascri
</HeaderTemplate>
ASKER
Yeah, it's already in a template column:
Segment:
<asp:TemplateColumn>
<HeaderTemplate>
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged="javascri pt: 'return select_deselectAll(this.ch ecked, this.id)';" runat="server"></asp:Check Box>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="cbxACH" OnCheckedChanged="javascri pt: return select_deselectAll(this.ch ecked, this.id);" runat="server"></asp:Check Box>
</ItemTemplate>
</asp:TemplateColumn>
Javascript:
function select_deselectAll(chkVal, idVal)
{
var frm = document.forms[0];
// Loop through all elements
for (i=0; i<frm.length; i++)
{
// Look for our Header Template's Checkbox
if (idVal.indexOf('CheckAll') != -1)
{
// Check if main checkbox is checked, then select or deselect datagrid checkboxes
if(chkVal == true)
{
frm.elements[i].checked = true;
}
else
{
frm.elements[i].checked = false;
}
// Work here with the Item Template's multiple checkboxes
}
else if (idVal.indexOf('DeleteThis ') != -1)
{
// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
if(frm.elements[i].checked == false)
{
frm.elements[1].checked = false; //Uncheck main select all checkbox
}
}
}
Segment:
<asp:TemplateColumn>
<HeaderTemplate>
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged="javascri
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="cbxACH" OnCheckedChanged="javascri
</ItemTemplate>
</asp:TemplateColumn>
Javascript:
function select_deselectAll(chkVal,
{
var frm = document.forms[0];
// Loop through all elements
for (i=0; i<frm.length; i++)
{
// Look for our Header Template's Checkbox
if (idVal.indexOf('CheckAll')
{
// Check if main checkbox is checked, then select or deselect datagrid checkboxes
if(chkVal == true)
{
frm.elements[i].checked = true;
}
else
{
frm.elements[i].checked = false;
}
// Work here with the Item Template's multiple checkboxes
}
else if (idVal.indexOf('DeleteThis
{
// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox
if(frm.elements[i].checked
{
frm.elements[1].checked = false; //Uncheck main select all checkbox
}
}
}
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged=
i guee onClick is the rightevent not OnCheckChanged
i guee onClick is the rightevent not OnCheckChanged
ASKER
Visual Studio.NET doesn't recognize an onClick event, just an OnCheckedChanged...
ASKER
for checkboxes that is...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
SON OF A....
That drives me nuts... It works now, changing those OnCheckedChanged to onClick. I suppose Microsoft doesn't recognize the problem, either, since MSDN doesn't have any info on it.
Well, thanks for that. I'll keep that tidbit in my quiver for some time to come.
Nick
That drives me nuts... It works now, changing those OnCheckedChanged to onClick. I suppose Microsoft doesn't recognize the problem, either, since MSDN doesn't have any info on it.
Well, thanks for that. I'll keep that tidbit in my quiver for some time to come.
Nick
<HeaderTemplate></HeaderTe
is it in template column
"javascript: return select_deselectAll(this.ch
post the javascript code too...