Reputation: 2499
I have got an issue after updation in UpdatePanel. The issue is the jquery events are not working/firing after the updation in UpdatePanel. At first time, the jquery events work, but not after the updation in UpdatePanel. If I remove the UpdatePanel, the problem is solved. But I have to use the UpdatePanel.
Can you give me a solution for this ?
Upvotes: 0
Views: 886
Reputation: 55740
You need to bind the Events or the functions that you want to execute even after the page postbacks as the elements do not remember the events attached to them after postback..
So you need call them in the endRequst handler
$(function{
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(AfterPostBack);
AfterPostBack();
});
function AfterPostback(){
// Your code goes here...
}
Upvotes: 0
Reputation: 1038720
One of the possible reasons for this is that the UpdatePanel
replaces elements in the DOM that had jquery events attached to them which of course nullifies those events. One possible solution would be to use the .live()
function to register events but it works only with some events.
If you can't use the live
function you will need to reattach those events once the UpdatePanel
has finished replacing DOM elements:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(sender, args) {
// TODO: reattach your jquery event handlers
});
Upvotes: 2