This
article will show you how you can assign client side click event to button
control using jquery in asp.net. So in this I have shown how the alert message
will come after assigning the click event of asp.net button.
Some of my
previous articles are as follows: Enable
Or Disable All GridView Button On Check Of CheckBox Using jQuery, Ajax
GridView Shorting Without Page Refresh Using jQuery In Asp.net and C#.Net, Enable
Or Disable GridView Button By Row CheckBox Using jQuery In Asp.Net, jQuery
Top Right ToolTip On Hyper Link With Question Mark Sign On Mouse Cursor In
Asp.net, Export
GridView Or Table Data Into PDF By C#.Net In Asp.Net Using jQuery, Export
GridView Or Table Data Into jSon Format Data By C#.Net In Asp.Net Using jQuery, Bind
GridView To DataTable and Convert GridView Data Into Chart In Asp.Bet Using
jQuery.
So for this
article first we will create a new asp.net application and add the fellow
reference in the header of the page.
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
|
After this add the below button code to display the button
control.
<body>
<form id="form1" runat="server">
<div>
Click
Me :
<asp:Button ID="Button1" runat="server" Text="Validate Cleint Side Click Event" />
</div>
</form>
</body>
|
Now check the below jQuery click function code to assign the
click event.
$(document).ready(function () {
$("#<%=Button1.ClientID%>").click(function () {
alert("This is click event
of button.");
});
});
|
Here in document.ready I have used click function to assign the event to the button control by using ClientId. So after execution as used click on button the assign alert message will appear. You can write your own code to perform operation as per your requirement.
0 comments:
Please let me know your view