UncleCoder.com

UncleCoder.com

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

Edited on 01 Jan 0001


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

DEMO

Client Side code

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

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:


Advertisement