When you have multiple UpdatePanels on a page, is there a way, in the code behind, find out which Update Panel triggerred the postback? It appears that the Request["__EVENTTARGET"]
is not a reliable way of doing this.
views:
17answers:
2
+1
A:
An UpdatePanel doesn't trigger PostBacks, it intercepts them. The originator of the PostBack would be something like a button. If you have event handlers for all your interactive elements, you naturally know which one fired by which event handler runs.
Rex M
2009-10-02 15:10:27
Yes, I should have said "control in an Update Panel triggerred the postback". I have multiple instances of the same user control that has an updatepanel within it.
2009-10-02 15:15:36
@unknown so the event handler in the correct instance of the user control should fire. It might be easier to help if we know what you're trying to accomplish.
Rex M
2009-10-02 15:23:17
A:
you can get the id of the postback element on the client with the following
function pageLoad(sender, args) {
// add function to the PageRequestManager to be executed on async postback initialize
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
}
function InitializeRequest(sender, args) {
if(args._postBackElement.id === 'id_of_element_in_question' {
// do whatever
}
}
to get it on the server, presumably you'll know which control/event raised the postback as it will be handled in the relevant event handler in the code-behind.
Russ Cam
2009-10-02 15:18:19