开发者

Accessing and binding events to an ASP.NET Grid view using Jquery

I have an ASP page which displays a text box when it loads. It takes an input number, send it to the server through post back, and then displays some record in a grid view. After a number is input into the box, the server fetches some data from a database and add records to the grid view. It also contains a link column, whose URL is set to "#", so that the page isn't redirected when it is clicked.

Now I want to bind a jquery "click" event to that link. How can I do that ? I have tried that to do myself but failed, because it is not available 开发者_如何学Gowhen the DOM is loaded (since it only contains rows when a number is input through the box), and is being modified through ASP.NET Ajax post back.


You should be able to use the live handlers in jQuery to do this. I'd give these links a specific class to uniquely identify them and make it easier.

 $('a.gridLink').live('click', function() {
     ... perform your action...
     return false; // to cancel the default click action
 });


i think you're looking for .live.


You need to call the live function:

$('#<%=myGrid.ClientID%> a').live("click", function(e) {
    //Do things
    return false;  //You don't need to set the href to #
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜