Saturday, 1 June 2013

How to call java script function from code behind file in


 Declare a JavaScript function in the head tag of your design file as shown below:

<head runat="server">
    <title>Calling JavaScript From CodeBehind in file</title>
    <script type="text/javascript">
        function MyFunction() {
            alert('Demonstration Successfull..');

In order to call it from code behind, use the following code in your Page_Load

protected void Page_Load(object sender, EventArgs e)
    if (!ClientScript.IsStartupScriptRegistered("alert"))
            "alert", "MyFunction();", true);

No comments:

Post a Comment