Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag 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 Ioannis Paraskevopoulos
Ioannis Paraskevopoulos
Flag of Greece image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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


Did it finally work? I was about to have a look on it. I didn't have time the rest of the day :)