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

Hi,

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

Open in new window


Giannis
Avatar of Mike Eghtebas

ASKER

Hi  jyparask,

If this is what you mean:

<Script>
Function fnEnableEmailBox(bolCheched As Boolean) {

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

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'.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.