0

I have an asp button on my page, in the Page_Load on the code behind, I am binding some javascript calls as follows.

btnExample.OnClientClicking = "functionOne(1,2);"+"function2()";

The problem is I would like to be able to pass the EventArgs passed to the Page_Load as in function2() I wish to call...

eventArgs.set_cancel(true).

Would appreciate any help.

2
  • I don't think it's clear from your question exactly what your trying to do, maybe rephrase the question or add some more details. Commented Feb 6, 2009 at 14:51
  • Yea please give more detail of what you are trying to do.Are you trying to click a button and in code behind do something when the button is clicked, and what exactly are you trying to do when the button is clicked? Commented Feb 6, 2009 at 15:34

2 Answers 2

1

If you are trying to prevent the post back, Sachin is correct you must return false. Don't forget that in addition to adding return false to your JavaScript function you must also add return when assigning 'OnClientClick'.

Code Behind:

btnExample.OnClientClick = "functionOne(1,2); return function2();";

JavaScript:

function function2()
{
    //Do something
    return false;
}
Sign up to request clarification or add additional context in comments.

Comments

1

As far as I am able to understand your question, you can write "return false;" in function2().
This will also ensures that server side click event of btnExample will not gets fired.

2 Comments

Hey, thanks for the suggestion. However, return false does not work, it still skips server side.
"skips to server side" I mean. Typo.

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.