javascriptasp.netserverside-javascript

Executing JavaScript from the server code in asp.net


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.


Solution

  • 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.