<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>foo, bar and donkey : Modal Popup</title><link>http://blogs.msdn.com/kirti/archive/tags/Modal+Popup/default.aspx</link><description>Tags: Modal Popup</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Using UpdatePanels with ModalPopups</title><link>http://blogs.msdn.com/kirti/archive/2008/07/31/using-updatepanels-with-modalpopups.aspx</link><pubDate>Thu, 31 Jul 2008 20:19:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8793780</guid><dc:creator>kirtid</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/kirti/comments/8793780.aspx</comments><wfw:commentRss>http://blogs.msdn.com/kirti/commentrss.aspx?PostID=8793780</wfw:commentRss><wfw:comment>http://blogs.msdn.com/kirti/rsscomments.aspx?PostID=8793780</wfw:comment><description>&lt;p mce_keep="true"&gt;&lt;em&gt;Moving an old post over from my old Technet blog to this MSDN blog.&lt;/em&gt;&lt;/p&gt;  &lt;p mce_keep="true"&gt;One of the most frequently asked questions on the &lt;a class="" title="Toolkit Sample Website" href="http://ajax.asp.net/ajaxtoolkit" mce_href="http://ajax.asp.net/ajaxtoolkit"&gt;Toolkit&lt;/a&gt; &lt;a class="" title="Toolkit forums" href="http://forums.asp.net/1022/ShowForum.aspx" mce_href="http://forums.asp.net/1022/ShowForum.aspx"&gt;forums&lt;/a&gt; and at &lt;a class="" title="MIX website" href="http://www.visitmix.com/" mce_href="http://www.visitmix.com"&gt;MIX&lt;/a&gt; after &lt;a class="" title="Shawn&amp;#39;s demo blog post" href="http://blogs.msdn.com/sburke/archive/2007/05/01/slides-and-demos-for-mix-toolkit-talk.aspx" mce_href="http://blogs.msdn.com/sburke/archive/2007/05/01/slides-and-demos-for-mix-toolkit-talk.aspx"&gt;Shawn's demo&lt;/a&gt; was how to get &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanels&lt;/a&gt; to work right with &lt;a class="" title="Modal Popup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopups&lt;/a&gt;. The trick is to understand that the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; extender attaches itself to more than just the TargetControl and PopupControl. If you include the OK and Cancel buttons inside the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; Panel in an &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanel&lt;/a&gt;, make sure you include the extender declaration in it as well. If you do not, once a postback occurs the extender will not reinitialize the handlers and you will get null references. Also, if buttons inside the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; Panel are set to be OK and Cancel buttons on the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; Extender, then their sole purpose is to close the Popup Panel and run their respective scripts if any have been set. They will not perform postbacks or execute any other client side handlers since the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; prevents the event from propagating up. &lt;/p&gt;  &lt;p mce_keep="true"&gt;I have attached a sample page that demonstrates three simple scenarios with ModalPopups and UpdatePanels.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;     &lt;div mce_keep="true"&gt;&lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;&lt;strong&gt;ModalPopup&lt;/strong&gt;&lt;/a&gt;&amp;#160;&lt;strong&gt;with an &lt;/strong&gt;&lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;&lt;strong&gt;UpdatePanel&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt; inside its Popup Panel:&lt;/strong&gt; Make sure that the OK and Cancel buttons are not inside the &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanel&lt;/a&gt; otherwise the handlers will be rendered useless on postback. &lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div mce_keep="true"&gt;&lt;strong&gt;&lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;&lt;strong&gt;UpdatePanel&lt;/strong&gt;&lt;/a&gt; that contains a &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;&lt;strong&gt;ModalPopup&lt;/strong&gt;&lt;/a&gt; Extender and its Popup Panel: &lt;/strong&gt;Clicking OK or Cancel still does not cause the postback since those buttons are tied to client side handlers. Clicking on any other control will cause the server side handlers to kick in. Since the extender declaration is inside the UpdatePanel, the asynchronous postback causes the ModalPopupBehavior to be reinitialized correctly and any client side handlers are setup again when the request is completed. So if you would like to postback every time the user clicks OK or Cancel, just don't set those properties on the extender. The Modal Popup Panel closes on postback as desired since the entire popup is inside an &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanel&lt;/a&gt;.&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div mce_keep="true"&gt;&lt;strong&gt;What if that Popup Panel in # (2) contains an &lt;/strong&gt;&lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;&lt;strong&gt;UpdatePanel&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;: &lt;/strong&gt;Specify the triggers that will cause the outer panel to update and allow the &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanel&lt;/a&gt; inside the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; to operate on its own terms. This time the &lt;a class="" title="ModalPopup sample" href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx" mce_href="http://ajax.asp.net/ajaxtoolkit/ModalPopup/ModalPopup.aspx"&gt;ModalPopup&lt;/a&gt; Panel does not close on postback triggered from within it because the trigger for the outer panel is specifically set to be a separate button.&lt;/div&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p mce_keep="true"&gt;It is a good idea to design the page without &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanels&lt;/a&gt; in mind. When writing the page place &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanels&lt;/a&gt; when the rest is done. Once you have the page setup, determine locations in your page that need to be asynchronously updated and the controls that should act as triggers to perform that operation and then appropriately place &lt;a class="" title="Update Panel documentation" href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx" mce_href="http://ajax.asp.net/docs/mref/T_System_Web_UI_UpdatePanel.aspx"&gt;UpdatePanels&lt;/a&gt; with the correct triggers and UpdateMode property set. With extenders it is important that you take into consideration not just the controls targetted by the extender but any others which it hooks into to provide additional functionality. &lt;/p&gt;  &lt;p mce_keep="true"&gt;This post should evolve as I get more feedback and I will update the sample accordingly as well. I hope this helps.&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8793780" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/kirti/archive/tags/AJAX+Control+Toolkit/default.aspx">AJAX Control Toolkit</category><category domain="http://blogs.msdn.com/kirti/archive/tags/Update+Panel/default.aspx">Update Panel</category><category domain="http://blogs.msdn.com/kirti/archive/tags/Modal+Popup/default.aspx">Modal Popup</category></item></channel></rss>