I have an asp.net button, that when clicked calls a code behind function. The function does some evaluation, and then I want to call javascript from within this asp.net function.
Javascript – Call javascript function from asp.net code behind after server side code executes
asp.netjavascript
Related Topic
- Javascript – How to loop through or enumerate a JavaScript object
- Javascript – the !! (not not) operator in JavaScript
- Javascript – Creating multiline strings in JavaScript
- Javascript – Set a default parameter value for a JavaScript function
- Javascript – the JavaScript version of sleep()
- Javascript – What does “use strict” do in JavaScript, and what is the reasoning behind it
- Javascript – Why does Google prepend while(1); to their JSON responses
- Javascript – How to return the response from an asynchronous call
Best Answer
While pranay's answer is correct in the function call, the rest is off, here's hopefully a better explanation:
You can use
ClientScript.RegisterStartupScript()
to do what you want, like this:The format is
(type, scriptKey, scriptText, wrapItInScriptTags)
.If you are operating with an UpdatePanel, it's very similar, except you need to use the slightly different
ScriptManager.ResgisterStartupScript()
. Use the UpdatePanel as the control and type parameters in that case to be safe.