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
ASP.NET

Avatar of undefined
Last Comment
Mike Eghtebas
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
Mike Eghtebas
Flag of United States of America image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

ASKER

Thank you.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo