How to call function using Jquery on button click event ?


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 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 () {


        function Sayhello() {
            alert("Hello from Jquery");

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:Button ID="btnClick" runat="server" Text="Click Here" />


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.