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. |
|||
|
|||
4 comments :
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
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
good post keep it up.
Good but need to answer above questions.I also have same question.
Note: Only a member of this blog may post a comment.