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

No comments:

Post a Comment