Avatar of Mike Eghtebas
Mike Eghtebas
Flag for United States of America asked on

event not firing... asp 4

Protected Sub chkEmailUpdates_CheckedChanged(sender As Object, e As System.EventArgs) Handles chkEmailUpdates.CheckedChanged
        requireName.Enabled = chkEmailUpdates.Checked
End Sub

Open in new window

with tag:
<asp:CheckBox ID="chkEmailUpdates" runat="server" Text="Email me updates"  />

Open in new window

Question: Why this event (chkEmailUpdates_CheckedChanged) is not firing when it is checked or unchecked?

Thank you.

Avatar of undefined
Last Comment
Ioannis Paraskevopoulos

8/22/2022 - Mon
Ioannis Paraskevopoulos

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mike Eghtebas

Hi Giannis,

I tried but for some reason it is not working.

I have the following javascript working for me doing some other tasks. I wonder if we could change this script to respond to chkEmailUpdates_CheckedChanged and also include

requireEmail.Enabled = chkEmailUpdates.Checked

This is vb version, I suppose I need to use setAttribute or something similar in javascript below to accomplish that.
        <script type="text/javascript">

            // to anonymous function are created to help with chkBox functionalities
            window.onload = function () {
                document.getElementById("<%= chkEmailUpdates.ClientID %>").onchange = function () {
                    var txtAddress = document.getElementById("<%= txtAddress.ClientID %>");
                    txtAddress.disabled = !this.checked;
                    if (!this.checked) txtAddress.value = "";
                    if (this.checked) txtAddress.focus();
                    txtAddress.setAttribute('CausesValidation = " + txtAddress """');
                // on document first-time load chkAddComment is false therefore it has to be set to none
                document.getElementById("CommentRow").style.display = (document.getElementById("<%= chkAddComment.ClientID %>").checked) ? "block" : "none";
                document.getElementById("<%= chkAddComment.ClientID %>").onchange = function () {
                    if (this.checked) {
                        document.getElementById("CommentRow").style.display = "block";
                    } else {
                        document.getElementById("CommentRow").style.display = "none";

Open in new window


Ioannis Paraskevopoulos

Did it finally work? I was about to have a look on it. I didn't have time the rest of the day :)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.