Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / September 2006



Tip: Looking for answers? Try searching our database.

Fire up checkbox onclick event from asp.net codebehind

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ccordero@gmx.net - 29 Sep 2006 20:43 GMT
Hi!

I am working with asp.net 1.1 and javascript.

I have a client side checkbox, a client side button, and an asp.net
image button.

When I check the checkbox, I want the client side button to disable,
and I want the same button enebled if I uncheck the checkbox.

I have the checkbox_onclick javascript function needed to do that and
it is working fine.

The problem is that in the asp.net image button Click event (code
behind), I change programatically the checkbox value, depending on a
value queried from a database, and when this value is changed, it
doesn't fire up the checkbox javascript onclick handler, so, the
checkbox value changes, but not the disabled property of the client
side button.   :'(

I would appreciate any help!

Thank you!
ccordero@gmx.net - 29 Sep 2006 21:05 GMT
I forgot to mention both client side checkbox and button controls have
the attribute:  runat="server"

Thank you!
Gozirra - 29 Sep 2006 21:51 GMT
Is there a reason you can't disable the control from code-behind like
this?

if (dbValue == "whatever")
{
   theControl.Enabled = false;
   etc....
}

If that doesn't work for you, my other suggestion would be to create a
simple bit of javascript that runs on load.  If a certain condition is
met you fire the script to configure the controls on the page to match
whatever you need.

function afunc()
{
   if ( 1 == <%= runme %>)
       callTheClickFunction();
}

runme would be a variable or property you would set from code-behind.
You will still need to do something similar in code-behind as I showed
you before but now you can let the javascript handle enabling/disabling
the appropriate controls.

Thats all I got for now.  Hope this helps.

> I forgot to mention both client side checkbox and button controls have
> the attribute:  runat="server"
>
> Thank you!
ccordero@gmx.net - 29 Sep 2006 22:29 GMT
Thank you Gozirra.

I made a mistake in my last post:  the client side button which I want
to disable/enable programatically, must be precisely just client side
(it doesn't have runat="server" attribute like I said before), because
it makes some tasks related with digital signature with Capicom
library.

That's why I can't access its .Enabled property from aspx code-behind,
or at least I don't know how to do that without converting it to a
server control.

I will try the second approach.

Thank you very much!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.