Friday, May 10, 2013

Call Javascript function from codebehind page (Asp.Net)

If you want to alert some thing then this will be very useful to you.:

Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "javascript:alert('sss');", true); 

If you want to call a javascript function  then this will be very useful to you.:

In code behind page:(aspx.cs)
Page.ClientScript.RegisterStartupScript(this.GetType(), "Call my function", "myJavaScriptFunction()", true); 

In (aspx):
<script type="text/javascript">
    function myJavaScriptFunction() 
                  {
                            //Do your javascript here
                  }
</script>

2 comments:

  1. Hi,

    If this post is helpful to you then please rate this.

    Thanks
    Sibasis

    ReplyDelete