?
Solved

Error in a simple javascript call from a checkbox 'OnCheckedChange'

Posted on 2005-02-24
7
Medium Priority
?
658 Views
Last Modified: 2008-01-09
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
Comment
Question by:sharpnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:praneetha
ID: 13394351
<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
 
LVL 3

Author Comment

by:sharpnet
ID: 13394391
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
 
LVL 15

Expert Comment

by:praneetha
ID: 13394394
<asp:CheckBox ID="cbxACHAll" OnCheckedChanged=

i guee onClick is the rightevent not OnCheckChanged
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:sharpnet
ID: 13394467
Visual Studio.NET doesn't recognize an onClick event, just an OnCheckedChanged...
0
 
LVL 3

Author Comment

by:sharpnet
ID: 13394471
for checkboxes that is...
0
 
LVL 15

Accepted Solution

by:
praneetha earned 2000 total points
ID: 13394510
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
 
LVL 3

Author Comment

by:sharpnet
ID: 13394577
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question