ASP.NET Checkbox onclick with javascript

Posted on 2006-05-03
Last Modified: 2008-01-09
Hi All,

I'm really scratching my head on why this isn't working.  

Here is my checkbox:
<asp:CheckBox Runat="server" Checked=False id="ApplyFutureDate"></asp:CheckBox>

Here is my code behind:
Protected WithEvents ApplyFutureDate As New System.Web.UI.WebControls.CheckBox

ApplyFutureDate.Attributes.Add("onClick", "javascript:ApplyFutureDate(this)")

For some reason why I run this, I get a javascript error saying: Object doesn't support this property of method

I even tried OnCheckedChanged and that didnt' work either.


Question by:muligan

    Author Comment

    BTW... here is my sample javascript that doesn't run:

    function ApplyFutureDate(obj)
    //return true;    
    LVL 52

    Accepted Solution

    I think its a name conflict between your function and the checkbox name. Try changing your javascript function name.

    Author Comment

    by:muligan could it be that easy?  For learned purposes... why would the same name cause a conflict?
    LVL 52

    Expert Comment

    by:Carl Tawn
    Because ApplyFutureDate has two meanings on the one hand it is a function and on the other it is a checkbox control. When searching for a match the code will bubble, that is it will bubble up the document structure until it finds a match. In your case, the first match it found for ApplyFutureDate was the control, so it tried to execute ApplyFutureDate(this) against the control, which, of course, doesn't have any methods that accpet an object.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    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…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now