in

ASP.NET Weblogs

This Blog

Syndication

News




NOTE: The opinions expressed here are MY OWN and are not necessarily those of my employer, partners, customers, friends, or family. ALL content presented AS-IS, for entertainment purposes only with ABSOLUTLY NO WARRANTY expressed or implied.

Joe On ASP.NET

Multiple UpdatePanels - Who caused the update ?

Does your client code need to know what control caused your update panels to update or which of several UpdatePanels contained the triggering control ? Try this.... (Or do the same thing with addbeginRequest();

    1 <script type="text/javascript">
    2 <!--
    3 var prm = Sys.WebForms.PageRequestManager.getInstance();
    4 
    5 prm.add_endRequest(EndRequest);
    7 function EndRequest(sender,args)
    8     {
    9     alert(sender._postBackSettings.panelID + " -> " + sender._postBackSettings.sourceElement.id);
   10     }
   11  -->
   12 </script>


Note that "id" contains the id of the CONTROL that caused the postback. panelId contains a string that appends the event trigger with the UpdatePanel name.   Note that if the update was caused by an event configured in the Triggers Collection or updated explicitly in JavaScript, the "Control" name will be the UpdatePanel.

Published Apr 19 2008, 11:01 AM by JoeStagner
Filed under: ,

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About JoeStagner

Joe Stagner is a Senior Program Manager in Microsoft Corporation’s Developer Tools and Platform Group and has been with Microsoft since 2001 focusing on highly scalable and performant web application architectures, multiplatform interoperability and software security. Joe brings 30 years technical and business strategy experience to Microsoft which affords him a unique experiential perspective. [ I am NOT able to respond to PMs - please contact me via www.MisfitGeek.com ]