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?

2
  • what do you actually want to do? you want when the checkbox is checked to trigger an event in server side, or you want to make another element do something? Commented May 15, 2009 at 4:11
  • I am eventually going to replace the return false call with a method call that returns false but does other stuff like hiding/displaying controls. If the user has Javascript enabled, I want this method to handle it on the client side, otherwise I want my server side event to run. Commented May 15, 2009 at 4:19

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

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 - The autopostback is done using javascript, so if javascript is not available then the autopostback would not work.
Ahhh... I see what you're saying now. Sorry for the misunderstanding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.