Saturday 5 May 2012

Register Client Script Include in ASP.NET


Add button control to a page

<asp:Button ID="Button1" runat="server" Text="Button"  OnClientClick="alertme()"/>

protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager csm=this.ClientScript;
            csm.RegisterClientScriptInclude(this.GetType(),"mybuttonclick", "js/scrip1.js");
}

add folder called  js
add file called scrip1.js
  add following code shown below

   function alertme() {
    alert('button clicked');
}

No comments:

Post a Comment