Fire up checkbox onclick event from asp.net codebehind

C

ccordero

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!
 
C

ccordero

I forgot to mention both client side checkbox and button controls have
the attribute: runat="server"

Thank you!
 
G

Gozirra

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

ccordero

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top