Follow by Email

Friday, September 13, 2013

example to call a javascript function from code-behind or server-code using ScriptManager in asp.net,c#

hi in this post i will show how to call a javascript function from codebehind in asp.net :

Example:

aspx.cs page(codebehind):

 protected void testMethod()
    {
 ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage1", "ShowalertMessage();", true);
    }

aspx page:
 <script type="text/javascript" language="javascript">
  function ShowalertMessage() {
            alert('hello world!');
        }
    </script>