I have a script that runs once an update panel fires: Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); function EndRequestHandler(sender, args) { initDropSearch(); } function initDropSearch() {
var search = jQuery("#searchBar div.productSearchFilter");
if (search.length > 0) {
va开发者_Python百科r grid = search.find("table.gridView");
if (search.next().val() != "open") {
search.animate({
height: ['toggle', 'easeOutBounce'],
opacity: 'toggle'
}, 1000)
.next().val("open");
} else {
search.show();
}
}
}
Once the results of a search have loaded, the container drops down and bounces.
It works perfectly - that is until another update panel is triggered on the same page - in which case the search panel opens again.
What I need to do is only run the script when a specific updatePanel fires.
Is there a way to do this?
Do the sender
or args
contain data about the UpdatePanel that triggered the EndRequestHandler
?
If so just check which one triggered it and only fire your code based on that.
function EndRequestHandler(sender, args) {
if (((UpdatePanel)sender).ID == "UpdatePanel1") {
initDropSearch();
}
}
精彩评论