March 26, 2009

How to quickly add a Key Up Event to all TextBoxes in an ASP.NET GridView or Table control




The quickest way to add the KeyUp event to all textboxes in a HTML Table or ASP.NET GridView control is to use jQuery. Here's how


<head runat="server">


<title></title>


<script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>


<script type="text/javascript">


$(document).ready(function() {


$("#GridView1 tr :text").keyup(function() {


alert('');


});


});


</script>


</head>




Here we are assuming that the table has an Id like this <table id="GridView1"> Also remember that the ASP.NET GridView renders as a table

If you haven't downloaded the latest version of jQuery yet, here are some links:

Latest jQuery and jQuery UI Theme links on Google CDN

'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

0 Responses to "How to quickly add a Key Up Event to all TextBoxes in an ASP.NET GridView or Table control"
 

Copyright © 2009-2012 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions