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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.