1

Is it possible to fire the onclientclick after the onclick event for asp.net button? I am sending some values in session from onclick event and then I want to fire onclientclick. Any help would be advisable.

3
  • I believe that can not be happen. But you can use ajax. On client click go to server and write things to session. Commented Jun 28, 2013 at 9:08
  • I mean that can not be happen as you said it, without a trick. Commented Jun 28, 2013 at 9:15
  • It's highly unlikely that this is possible due to the OnClick being a postback that results in a new page, and the OnClientClick being a client side script function. Clearly the script of this page will happen before the result of the postback provides the new page, otherwise the script is no longer there. Commented Jun 28, 2013 at 9:16

2 Answers 2

2

You can call the javascript function using register client script inside the onclick of the button.

    ClientScript.RegisterStartupScript(Page.GetType, "Javascript", 
"YourButton_OnClientClick_Handler();", true);
Sign up to request clarification or add additional context in comments.

1 Comment

I am using the same but this is not opening the page in new tab(as my client side script opens a new tab), when I am calling same function from server side.
2

Are you using an Update Panel? If yes, capture the endrequest and write code there..

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);

Comments

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.