0

Here is what I need to do: I need to execute some server side code after a user clicks on a button, THEN I need to execute some client side code. OnClientClick gets invoked BEFORE the onClick; and what I need is the opposite.

Is there a way to do this? It looks like I will have to execute JS code from the server code.

2
  • 1
    Have the onClick do a synchronous AJAX call to the server as its first step. That ajax call will block the client until the call returns. Then things can continue with the client-side code. Commented Feb 16, 2011 at 21:19
  • 1
    My instinct says you can make the server side call using AJAX and then fire off a client side event once the request is complete. But, I say that not knowing how your project is setup. Strictly speaking, there's no way to make client calls from the server. (but you can usually fake it) Commented Feb 16, 2011 at 21:19

1 Answer 1

1

You could use RegisterStartupScript in the code behind of your app.

This would place the javascript code you need to be called in the body.onload event.

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

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.