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

OnCheckedChanged event... javascript

Upon checking chkEmailUpdates below:

<asp:CheckBox ID="chkSpecial" runat="server" Text="Email me updates" OnCheckedChanged="fncEnableEmailBox(Cheched)"  />

the text box below (txtAddress, already disabled)

<asp:TextBox ID="txtAddress" runat="server"  Enabled="False"></asp:TextBox>

is expected to fire fncEnableEmailBox() with an argument true or false to enable or disable txtAddress and also activate or deactivate its validation (unless validation is ignore when a control is disabled)?

Question: How is this done in javascript?

I suppose this could be done in vb itself without using javascript? But I suppose, javascript will be better because it doesn't involve a postback and updating the  disable/disable status of txtAddress in page onload event (using session variables). I appreciate some comments on this point.

Thank you

Avatar of undefined
Last Comment
Mike Eghtebas

8/22/2022 - Mon
Ioannis Paraskevopoulos


Try the following:
document.getElementById('txtAddress').disabled = true;

Open in new window

Mike Eghtebas

Hi  jyparask,

If this is what you mean:

Function fnEnableEmailBox(bolCheched As Boolean) {

      document.getElementById('txtAddress').disabled = bolCheched ;
     ' also this needs to be handled as well
     'if (bolCheched == false) { 
     '     txtAddress ="";

Open in new window

Then how to pass the value of bolCheched argument in:

OnCheckedChanged="fnEnableEmailBox(Cheched)"If so, I have the following error:

Compiler Error Message: BC30456: 'fnEnableEmailBox' is not a member of 'ASP.addcontact_aspx'.

Tom Beck

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

Thank you.
Your help has saved me hundreds of hours of internet surfing.