UncleCoder.com

UncleCoder.com

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: 719

Edited on 05 Jun 2017



DEMO

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">
    <div>
        <asp:Button ID="Button1" runat="server" Text="ClickMe" OnClick="Button1_Click" />
    </div>
    </form>

 

 

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:


Advertisement