Free programming examples and instructions

Asp.net - Execute javascript from server side

Demo and code for how to execute javascript from server side

by Athil

Posted on 01 Jan 0001 Category: Asp.net Views: 1972

Here I am going to show how to execute javascript from server side using ScriptManager.RegisterStartupScript method.


Client Side code

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

Server Side Code

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


Leave a Comment:

Click here to register

Popular articles