Free programming examples and instructions

Excecute Javascript from server side

Code and demo for how to execute javascript from server side

by Athil

Posted on 19 Mar 2017 Category: Asp.net Views: 1639

Edited on 05 Jun 2017


Hi here Iam going to show how to excecute javascript code from server side  usig  ScriptManager.RegisterStartupScript method.

For that Iam going to design a web page with button.

On Client Side

  <form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="ClickMe" OnClick="Button1_Click" />



On Server Side

  protected void Button1_Click(object sender, EventArgs e)
            ScriptManager.RegisterStartupScript(this, typeof(Page), "ScriptName", "<script>alert('hi');</script>", false);



Leave a Comment: