views:

1342

answers:

1

I'm trying to wire up a CheckBox to handle an event when check/unchecked. If the user has JavaScript enabled, use that, otherwise use a postback.

Here is my code:

<asp:CheckBox ID="ApplicationInProcessCheckBox" runat="server" 
    Text="Application In Process" AutoPostBack="true" 
    oncheckedchanged="ApplicationInProcessCheckBox_CheckedChanged"
    onclick="return false;" />

The return false in the javascript onclick event is disabling the postback. However, it also won't let the box check or uncheck. (I have more code to add to the javascript event... I just want to get the concept working first).

What am I doing wrong?

+1  A: 

I think we can't post back on clicking checkbox without javscript enabled.

Priyan R
I think you are misunderstanding. When I click this CheckBox, I want to disable/enable a textbox. If Javascript is enabled, I want to do it in Javascript with no postback. If not, I want the postback and code behind to handle it.
Mike C.
@Mike - The autopostback is done using javascript, so if javascript is not available then the autopostback would not work.
Nahom Tijnam
Ahhh... I see what you're saying now. Sorry for the misunderstanding.
Mike C.