Hi
So many time we will get scenario to call function using jquery on button click event. Even though this is one of frequently asked question in interview.
So here is the complete syntax for doing this task in asp.net master.
Note: Here i have already kept the jquery lib path reference in master page.
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> <script type="text/javascript"> // This synstax used for firing some action on click event // $(document).ready(function () { // $("#<%= btnClick.ClientID %>").click(function (event) { // alert("Hello"); // }); // }); $(document).ready(function () { $("#<%=btnClick.ClientID %>").bind('click', function () { Sayhello(); }); }); function Sayhello() { alert("Hello from Jquery"); } </script> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:Button ID="btnClick" runat="server" Text="Click Here" /> </asp:Content>