Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JQuery html or asp button click event in asp.net

Jun 26, 2012
Introduction

In this article I will explain how to use html button click event or asp button click events in asp.net using JQuery.

Description:

In previous article I explained how to show session timeout message before session expires in JQuery. In one situation I got requirement like implement some functionality in html button click event for that I used JQuery button click events. Here I will explain how to implement button click functionality in JQuery for html and asp button controls for that first open visual studio create new application and design your aspx page like this 


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>html and Asp.net button click event in asp.net</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//This function will raise when click on html button control
$("#btnHtml").click(function() {
showalert('HTML Button Clicked');
});
//This function will raise when click on asp button control
$("#<%=btnAsp.ClientID %>").click(function() {
showalert('Asp Button Clicked');
});
});
function showalert(btnText) {
alert(btnText)
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btnHtml" value="HTML Button" />
<asp:Button ID="btnAsp" Text="Asp Button" runat="server" />
</div>
</form>
</body>
</html>
Demo



If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

4 comments :

Unknown said...

Dear Sir,
when i click on asp button the show dialog but in after post back it hide automatically tell the reason and one i want to put text box in dialog box and button tell me the situation r better for me.

thanks
najibullah

Unknown said...

Dear sir,
when i click on asp button show me dialog box after post back it is automatically hide tell me reason and another i want to put textboxes and buttons of asp in dialog box please guide me

thanks
najibullah

Anonymous said...

good post keep it up.

Anonymous said...

Good but need to answer above questions.I also have same question.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.