• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 667
  • Last Modified:

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="javascript: return select_deselectAll(this.checked, this.id);" runat="server"></asp:CheckBox>
</HeaderTemplate>

0
sharpnet
Asked:
sharpnet
  • 4
  • 3
1 Solution
 
praneethaCommented:
<asp:TemplateColumn HeaderText="View">
            <HeaderTemplate></HeaderTemplate>

is it in template column

"javascript: return select_deselectAll(this.checked, this.id);"

post the javascript code too...

0
 
sharpnetAuthor Commented:
Yeah, it's already in a template column:

Segment:
<asp:TemplateColumn>
      <HeaderTemplate>
            <asp:CheckBox ID="cbxACHAll" OnCheckedChanged="javascript: 'return select_deselectAll(this.checked, this.id)';" runat="server"></asp:CheckBox>
      </HeaderTemplate>
      <ItemTemplate>
            <asp:CheckBox ID="cbxACH" OnCheckedChanged="javascript: return select_deselectAll(this.checked, this.id);" runat="server"></asp:CheckBox>
      </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
                        }
                  }
            }
0
 
praneethaCommented:
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged=

i guee onClick is the rightevent not OnCheckChanged
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
sharpnetAuthor Commented:
Visual Studio.NET doesn't recognize an onClick event, just an OnCheckedChanged...
0
 
sharpnetAuthor Commented:
for checkboxes that is...
0
 
praneethaCommented:
well it does...just try Onclick and run it..even though in designmode it may show redline saying it does not exist...but it does
0
 
sharpnetAuthor Commented:
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now