AnimationExtender with ModalPopuphttp://forums.asp.net/t/1318051.aspx/1?AnimationExtender+with+ModalPopupTue, 21 Jun 2011 07:46:16 -040013180512612308http://forums.asp.net/p/1318051/2612308.aspx/1?AnimationExtender+with+ModalPopupAnimationExtender with ModalPopup <p>Hi forum, I want to do a fade in when modal popups, so thought to combine animationExtender to the ModalPopup.</p> <p>Ive tried a few things but its not happening. Ive posted my code with out the animationextender as this is what I need help with. Many Thanks Paul!!!</p> <p>JS:</p> <p>function pageLoad() {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#36;addHandler(&#36;get(&quot;showModalPopupClientButton&quot;), 'click', showModalPopupViaClient);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#36;addHandler(&#36;get(&quot;hideModalPopupViaClientButton&quot;), 'click', hideModalPopupViaClient);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function showModalPopupViaClient(ev) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ev.preventDefault();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var modalPopupBehavior = &#36;find('programmaticModalPopupBehavior');<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modalPopupBehavior.show();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function hideModalPopupViaClient(ev) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ev.preventDefault();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var modalPopupBehavior = &#36;find('programmaticModalPopupBehavior');<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modalPopupBehavior.hide();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>&nbsp;</p> <p>modal:</p> <p>&lt;a id=&quot;showModalPopupClientButton&quot; class=&quot;nav&quot; href=&quot;http://forums.asp.net/AddPost.aspx?ForumID=1022#&quot;&gt;&lt;strong&gt; Click Here&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;</p> <p>&lt;asp:Button runat=&quot;server&quot; ID=&quot;hiddenTargetControlForModalPopup&quot; style=&quot;display:none&quot;/&gt;</p> <p>&lt;ajaxToolkit:ModalPopupExtender runat=&quot;server&quot; ID=&quot;programmaticModalPopup&quot;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BehaviorID=&quot;programmaticModalPopupBehavior&quot;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TargetControlID=&quot;hiddenTargetControlForModalPopup&quot;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PopupControlID=&quot;Popup&quot; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BackgroundCssClass=&quot;modalBackground&quot;&gt;<br> &lt;/ajaxToolkit:ModalPopupExtender&gt;</p> <p>&nbsp;</p> <p>Panel (which I want to fade in):</p> <p>&lt;asp:Panel runat=&quot;server&quot; ID=&quot;Popup&quot; Style=&quot;display: none; width: 600px; height: 400px; background-color: White;<br> &nbsp;&nbsp;&nbsp; border-width: 2px; border-color: #009933; border-style: solid; padding: 10px;&quot;&gt;<br> &nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp; &lt;img src=&quot;images/block.gif&quot; alt=&quot;&quot;/&gt;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div class=&quot;right&quot;&gt;&nbsp; <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -&lt;a id=&quot;hideModalPopupViaClientButton&quot; class=&quot;nav&quot; href=&quot;http://forums.asp.net/AddPost.aspx?ForumID=1022#&quot;&gt; close &lt;/a&gt;-<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/div&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br> &nbsp; <br> &lt;/asp:Panel&gt;</p> <p>&nbsp;</p> 2008-09-10T11:58:27-04:002624063http://forums.asp.net/p/1318051/2624063.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup Hi,<br> <br> To achieve your goal, I have built a test application based on your situation, please refer to the code and the comment in it:&nbsp; <blockquote><pre class="prettyprint">&lt;%@ Page Language=&quot;vb&quot; AutoEventWireup=&quot;false&quot; CodeBehind=&quot;TestModalAnimationFadeIn.aspx.vb&quot; Inherits=&quot;SoluTest_AnimationInUserControl.TestModalAnimationFadeIn&quot; %&gt; &lt;%@ Register Assembly=&quot;AjaxControlToolkit&quot; Namespace=&quot;AjaxControlToolkit&quot; TagPrefix=&quot;ajaxToolkit&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head runat=&quot;server&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;script type=&quot;text/javascript&quot;&gt; function pageLoad() { $addHandler($get(&quot;showModalPopupClientButton&quot;), 'click', showModalPopupViaClient); $addHandler($get(&quot;hideModalPopupViaClientButton&quot;), 'click', hideModalPopupViaClient); } function showModalPopupViaClient(ev) { ev.preventDefault(); var modalPopupBehavior = $find('programmaticModalPopupBehavior'); <b>$find(&quot;AEFadeIn&quot;).get_OnClickBehavior().play();</b> modalPopupBehavior.show(); } function hideModalPopupViaClient(ev) { ev.preventDefault(); var modalPopupBehavior = $find('programmaticModalPopupBehavior'); modalPopupBehavior.hide(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; &lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot; /&gt; &lt;ajaxToolkit:AnimationExtender ID=&quot;AEFadeIn&quot; runat=&quot;server&quot; Enabled=&quot;True&quot; TargetControlID=&quot;hfFadeIn&quot;&gt; &lt;Animations&gt; &lt;OnClick&gt; &lt;%-- We need set the AnimationTarget with the control which needs to make animation --%&gt; &lt;Sequence AnimationTarget=&quot;Popup&quot;&gt; &lt;%--The FadeIn and Display animation.--%&gt; &lt;FadeIn Duration=&quot;1&quot; MinimumOpacity=&quot;0&quot; MaximumOpacity=&quot;1&quot; /&gt; &lt;/Sequence&gt; &lt;/OnClick&gt; &lt;/Animations&gt; &lt;/ajaxToolkit:AnimationExtender&gt; &lt;%-- Dummy TargetControl HiddenField--%&gt; &lt;asp:HiddenField runat=&quot;server&quot; ID=&quot;hfFadeIn&quot; /&gt; &lt;%-- ************** --%&gt; &lt;a id=&quot;showModalPopupClientButton&quot; class=&quot;nav&quot; href=&quot;http://forums.asp.net/AddPost.aspx?ForumID=1022#&quot;&gt; &lt;strong&gt;Click Here&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt; &lt;asp:Button runat=&quot;server&quot; ID=&quot;hiddenTargetControlForModalPopup&quot; Style=&quot;display: none&quot; /&gt; &lt;ajaxToolkit:ModalPopupExtender runat=&quot;server&quot; ID=&quot;programmaticModalPopup&quot; BehaviorID=&quot;programmaticModalPopupBehavior&quot; TargetControlID=&quot;hiddenTargetControlForModalPopup&quot; PopupControlID=&quot;Popup&quot; BackgroundCssClass=&quot;modalBackground&quot;&gt; &lt;/ajaxToolkit:ModalPopupExtender&gt; &lt;asp:Panel runat=&quot;server&quot; ID=&quot;Popup&quot; Style=&quot;display: none; width: 600px; height: 400px; background-color: White; border-width: 2px; border-color: #009933; border-style: solid; padding: 10px;&quot;&gt; &lt;img src=&quot;images/block.gif&quot; alt=&quot;&quot; /&gt; &lt;div class=&quot;right&quot;&gt; -&lt;a id=&quot;hideModalPopupViaClientButton&quot; class=&quot;nav&quot; href=&quot;http://forums.asp.net/AddPost.aspx?ForumID=1022#&quot;&gt; close &lt;/a&gt;- &lt;/div&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre></blockquote> Have my code helped?<br> <br> Best regards,<br> <br> Zhi-Qiang Ni 2008-09-16T10:21:01-04:002635115http://forums.asp.net/p/1318051/2635115.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>Thanks Zhi-Qiang Ni, this was exactly the solution!!! adding the hidden button to fire animationExtender when launching the modalPopup,&nbsp;thanks for posting the code it made it easy to uderstendand. Its all good, cheers Paul</p> 2008-09-21T08:41:22-04:003526008http://forums.asp.net/p/1318051/3526008.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>Wow this works really good..How do i do the fade out? I tried onClose inside animation but didnt work. Thankx a lot!&nbsp;</p> 2009-11-22T00:13:45-05:003974153http://forums.asp.net/p/1318051/3974153.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>Hi, I have 2 improvment to the answer.</p> <p><br> </p> <p>the problem I faced with it (although it's a great solution) is that the Pageload function register the event to a specific control id given its name.</p> <p>when you use for example master page, or datagrid you don't really know the id, and in datagrid the id's are generated automatically.</p> <p><br> </p> <p>so I created these functions:</p> <p>function show(id) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#36;addHandler(&#36;get(id), 'click', showModalPopupViaClient);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function hide(id) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#36;addHandler(&#36;get(id), 'click', hideModalPopupViaClient);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p> <p>which I call on the onclick event of the controls you want to act upon.</p> <p>(you could have a global boolean telling you if you already registered the events or not, but thats just sementic).</p> <p><br> </p> <p>i also figured out how to fade out, as some one asked for in this thread.<br> </p> <p>and the complete code is:</p> <p>&nbsp;</p> <p><pre class="prettyprint">&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head id=&quot;Head1&quot; runat=&quot;server&quot;&gt; &lt;title&gt;&lt;/title&gt; &lt;script type=&quot;text/javascript&quot;&gt; function show(id) { $addHandler($get(id), 'click', showModalPopupViaClient); } function hide(id) { $addHandler($get(id), 'click', hideModalPopupViaClient); } function showModalPopupViaClient(ev) { ev.preventDefault(); var modalPopupBehavior = $find('programmaticModalPopupBehavior'); $find(&quot;AEFadeIn&quot;).get_OnClickBehavior().play(); modalPopupBehavior.show(); } function hideModalPopupViaClient(ev) { ev.preventDefault(); var modalPopupBehavior = $find('programmaticModalPopupBehavior'); $find(&quot;AEFadeOut&quot;).get_OnClickBehavior().play();</pre><pre class="prettyprint"> } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt; &lt;ajaxToolkit:AnimationExtender ID="AEFadeIn" runat="server" Enabled="True" TargetControlID="hfFadeIn"&gt; &lt;Animations&gt; &lt;OnClick&gt; &lt;%-- We need set the AnimationTarget with the control which needs to make animation --%&gt; &lt;Sequence AnimationTarget="Popup"&gt; &lt;%--The FadeIn and Display animation.--%&gt; &lt;FadeIn Duration="1" MinimumOpacity="0" MaximumOpacity="1" /&gt; &lt;/Sequence&gt; &lt;/OnClick&gt; &lt;/Animations&gt; &lt;/ajaxToolkit:AnimationExtender&gt; &lt;ajaxToolkit:AnimationExtender ID="AEFadeOut" runat="server" Enabled="True" TargetControlID="hfFadeIn"&gt; &lt;Animations&gt; &lt;OnClick&gt; &lt;%-- We need set the AnimationTarget with the control which needs to make animation --%&gt; &lt;Sequence AnimationTarget="Popup"&gt; &lt;%--The FadeOut and Display animation.--%&gt; &lt;FadeOut Duration="1" MinimumOpacity="0" MaximumOpacity="1" /&gt; &lt;/Sequence&gt; &lt;/OnClick&gt; &lt;/Animations&gt; &lt;/ajaxToolkit:AnimationExtender&gt; &lt;%-- Dummy TargetControl HiddenField--%&gt; &lt;asp:HiddenField runat="server" ID="hfFadeIn" /&gt; &lt;%-- ************** --%&gt; &lt;a id="showModalPopupClientButton" onclick="show(id)" class="nav" href="http://forums.asp.net/AddPost.aspx?ForumID=1022#"&gt; &lt;strong&gt;Click Here&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt; &lt;asp:Button runat="server" ID="hiddenTargetControlForModalPopup" Style="display: none" /&gt; &lt;ajaxToolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup" BehaviorID="programmaticModalPopupBehavior" TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="Popup" BackgroundCssClass="modalBackground"&gt; &lt;/ajaxToolkit:ModalPopupExtender&gt; &lt;asp:Panel runat="server" ID="Popup" Style="display: none; width: 600px; height: 400px; background-color: White; border-width: 2px; border-color: #009933; border-style: solid; padding: 10px;"&gt; &lt;img src="images/block.gif" alt="" /&gt; &lt;div class="right"&gt; -&lt;a id="hideModalPopupViaClientButton" onclick="hide(id)" class="nav" href="http://forums.asp.net/AddPost.aspx?ForumID=1022#"&gt; close &lt;/a&gt;- &lt;/div&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> </p> <p><br> <br> </p> <p>&nbsp;</p> 2010-07-15T10:13:12-04:004002310http://forums.asp.net/p/1318051/4002310.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>Thanks Ozba, nice piece of code! and welcome to the Forum, cheers P<br> </p> 2010-07-31T09:00:25-04:004003141http://forums.asp.net/p/1318051/4003141.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>Hi&nbsp;Ive tried implementing&nbsp;Ozba's modal fadein-out code, but its not working in Opera(10.60).</p> <p>Any&nbsp;Reason? </p> 2010-08-01T07:03:18-04:004470326http://forums.asp.net/p/1318051/4470326.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>I tried Ni's solution, it worked when it is a seperated html page. however, if I put it in an aspx page which has a master page, then it shows this error:</p> <p>Microsoft JScript runtime error: Unable to get value of the property 'get_OnClickBehavior': object is null or undefined</p> <p></p> <p>error pops at:</p> <p>&#36;find(&quot;AEFadeIn&quot;).get_OnClickBehavior().play();</p> <p></p> <p>&#36;find(&quot;AEFadeIn&quot;) returned null. anyone know how to fix?</p> <p></p> <p>the show(id)/hide(id) solution does not work for me.</p> <p></p> <p>using IE9 and VS 2010 express.</p> <p></p> <p></p> <p>thanks&nbsp;</p> 2011-06-21T07:32:35-04:004470356http://forums.asp.net/p/1318051/4470356.aspx/1?Re+AnimationExtender+with+ModalPopupRe: AnimationExtender with ModalPopup <p>it is weird, I added a bahaviorID for the fadeIn animation, then change this:</p> <p>function showModalPopupViaClient(ev) {<br> ev.preventDefault();<br> var modalPopupBehavior = &#36;find('programmaticModalPopupBehavior');<br> //if (&#36;find(&quot;AEFadeIn&quot;) != null) <br> {<br> &#36;find(&quot;FadeInBehaviorID&quot;).get_OnClickBehavior().play();<br> modalPopupBehavior.show();<br> }<br> <br> }<br> &nbsp;</p> <p>Then, it works fine. But, why it can find the object based on BehaviorID, but not the ID? anyone knows? thanks</p> 2011-06-21T07:46:16-04:00