Add javascript method to server side control

Posted by Rajni.Shekhar under ASP.NET category on | Points: 40 | Views : 2438
ltes say you have a button "submit" and want to call a javascript method in code behind.

<asp:button id="btnSubmit" Text="Submit" runat="server"/>

this.btnSubmit.Attributes.Add("onClick", "return validate();"); //javascript method name is validate();


this.btnSubmit.Attributes["onClick"]="javascript:return validate();";

Comments or Responses

Login to post response