Workaround for using Web Parts with AJAX 1.0 UpdatePanelhttp://forums.asp.net/t/1087200.aspx/1?Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelThu, 27 Aug 2009 15:04:20 -040010872001621227http://forums.asp.net/p/1087200/1621227.aspx/1?Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelWorkaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi All,</p> <p>Some of you will be pleased to know that I have produced a workaround to address the issue of WebPart Drag and Drop (and verb popup menus) not operating correctly inside of an update panel. </p> <p>It seems that the <a class="" href="http://channel9.msdn.com/ShowPost.aspx?PostID=291423" target="_blank"> functionality being shown off on channel 9</a> (using Ajax CTP) was only to tease us into thinking that this would be possible in Ajax 1.0 (the final release). </p> <p>Here are the details of the work around:</p> <font size="2"> <p><strong><u>AJAX 1.0 Compatible WebPartManager (Workaround)</u></strong></p> <p><strong>1. The Problem</strong></p> <p>ASP.NET Web Parts Drag and Drop facility and Drop down verbs menu does not operate correctly inside of an Microsoft AJAX 1.0 UpdatePanel.</p> <p><strong>2. Why is doesn't work</strong></p> <p>The WebPartManager is responsible for registering an include and start up script. This script provides Web Parts and zones with various client side functionality including drag and drop and drop down verb menus.</p> <p>When a control is placed inside of an Update Panel, the script is rendered and ran on the first render, but not on subsequent renders. Due to this, the client side functionality fails.</p> <p><strong>3. The Solution</strong></p> <p>The solution is simple. Inherit the WebPartManager, override the RenderClientScript Method and render the client scripts using the System.Web.UI.ScriptManager instead of the System.Web.UI.ClientScriptManager. The System.Web.UI.ScriptManager informs Ajax of the registered client scripts and ensures that they are rendered out and executed whenever an UpdatePanel is refreshed.</p> <p><strong>4. Using the AJAX 1.0 Compatible WebPartManager</strong></p> <p>i.&nbsp; <a class="" title="Download the solution" href="https://www.ahsa.com.au/documentation/AJAX.Compatible.WebPartManager.zip"> Download the&nbsp;Solution (includes source code)</a></p> <p>ii. Compile the project and add a reference to it in your web project.</p> <p>iii. Add the following Tag Mapping to the specified section of your web.config:</p> <pre class="prettyprint">&lt;configuration&gt; &lt;system.web&gt; &lt;pages&gt; &lt;tagMapping&gt; &lt;add tagType=&quot;System.Web.UI.WebControls.WebParts.WebPartManager&quot; mappedTagType=&quot;Sample.Web.UI.WebParts.WebPartManager, Sample.Web.UI.WebParts&quot;/&gt; &lt;/tagMapping&gt; &lt;/pages&gt; &lt;/system.web&gt; &lt;/configuration&gt;</pre> <p>&nbsp;iv. Use Web Parts as normal (There is no need to replace the System.Web.UI.WebControls.WebParts.WebPartManager with Sample.Web.UI.WebParts.WebPartManager as the above mapping will take care of this).</p> <p>&nbsp;</p> <p>Enjoy! [:D]</p> <p>&nbsp;</p> <p>David</font></p> 2007-03-15T03:34:25-04:001621392http://forums.asp.net/p/1087200/1621392.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi davior,</p> <p>That sounds great. Have you tried this workaround for the WebPartManager in ASP.Net AJAX Futures?</p> <p>Regards.</p> 2007-03-15T06:27:01-04:001622847http://forums.asp.net/p/1087200/1622847.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi <strong>spvlong, </strong></p> <p>I haven't tried it, but I am aware that the same problem exists with the <strong> Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager</strong> in <strong>Microsoft.Web.Preview</strong>. </p> <p>I'm sure the fix would work using this control (just change the class being inherited and the tag mapping), although I'm not sure why you would want to do this (or why they even included this control in the Futures release considering it doesnt work!??).</p> <p>Cheers</p> <p>David</p> 2007-03-16T00:22:21-04:001622867http://forums.asp.net/p/1087200/1622867.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Thanks so much for figuring this one out.&nbsp; Since I have been put on the spot for our future &quot;<a class="" title="What the heck does Joe mean &quot;Webbish&quot;?" href="http://www.gaertner.de/~schuma/not-too-webbish.gif">Webbish</a> awareness&quot; which includes portals and minimal postbacks I am sure this would have been an enormous woe for me very soon.&nbsp; </p> <p>Thanks, </p> 2007-03-16T01:02:58-04:001622941http://forums.asp.net/p/1087200/1622941.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi David,</p> <p>I use <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager </strong> for Drag and Drop support in FireFox so I would like to know if this workaround can apply to Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager.</p> <p>&nbsp;</p> <p>Thanks,</p> 2007-03-16T02:42:05-04:001623120http://forums.asp.net/p/1087200/1623120.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Does the WebpartManager need to be in the same UpdatePanel as the WebpartZone for this to work? I want to have one WebpartManager on the page and serveral TabPanels each containing an UpdatePanel that contains WebPartZones in various layouts. Is it posssible to render more than one update panel at a time so that I am always rendering the WebpartManager's UpdatePanel? </p> <p>Also this seem like a pretty easy fix - almost too good to be true -&nbsp; is there a reason MS dropped this funtionality from AJAX and the CTP?<br> </p> 2007-03-16T06:01:21-04:001624498http://forums.asp.net/p/1087200/1624498.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <blockquote><span class="icon-blockquote"></span> <h4>spvlong</h4> <p>I use <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager </strong> for Drag and Drop support in FireFox so I would like to know if this workaround can apply to Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager.</p> <p></p> </blockquote> <p></p> <p>Hi spvlong,</p> <p>I have done some investigation on this component and have found that for this workaround to work you would probably need to also update the include script for it to operate correctly with <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager</strong>. </p> <p>My guess is that the only differance between the normal WebPartManager and the one found in <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager </strong>is the include script. Based on this in order to get this workaround to work with the <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager</strong>. you would need to do the following:</p> <ol> <li>In the WebPartManager in my project change the class being inherited from the standard WebPartManager to <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager</strong>. </li><li>Replace the embeded WebPartManager.js file in my project with the one emitted from the <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager </strong>(it is currently a copy of the&nbsp;one emmitted from the standard WebPartManager). </li><li>Change the tag mapping to map from the <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager </strong>to the workaround <strong>WebPartManager</strong> </li><li>In your web project use the <strong>Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager (and WebPartZones)</strong></li></ol> <p>If this does not work my guess would be that the dynamically generated inline script being emitted from the futures WebPartManager is also&nbsp;differant to that of the standard WebPartManager. In this case this inline&nbsp;script would also need to be updated to match (I really don't think that this will be the case).</p> <p>I will have a more detailed look into this if and&nbsp;when I get a chance.</p> <p>Cheers</p> <p>David</p> <p>&nbsp;</p> 2007-03-17T04:16:33-04:001626889http://forums.asp.net/p/1087200/1626889.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>I tried this solution and it appears to work fairly well for firefox, yet in IE I can only drag and drop a webpart once into another zone, then i cannot drag it into another zone anymore?</p> <p>Would you know any reason why this would happen?&nbsp;</p> 2007-03-19T17:09:32-04:001628297http://forums.asp.net/p/1087200/1628297.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p><a href="http://www.magicajax.net/">http://www.magicajax.net/</a></p> <p>Using the magic ajax update panel requires no work around and works great for using ajax&nbsp;with your webpart page.</p> 2007-03-20T12:32:02-04:001629463http://forums.asp.net/p/1087200/1629463.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Are you using the solution I linked to in the first post in this tread?</p> <p>Have you made any changes to this?</p> <p>If you are using the solution linked to in the first post, then i would imagine that it should work in IE and not in Firefox.</p> <p>Have you followed the instructions in the readme of the project? Tag mappings etc.?</p> <p>My guess is, that the webpart manager you are using is the standard one and not the modified one provided...</p> <p>Cheers</p> <p>David</p> 2007-03-21T03:35:06-04:001629546http://forums.asp.net/p/1087200/1629546.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <blockquote><span class="icon-blockquote"></span> <h4>matt_cyr</h4> <p>I tried this solution and it appears to work fairly well for firefox, yet in IE I can only drag and drop a webpart once into another zone, then i cannot drag it into another zone anymore?</p> <p>Would you know any reason why this would happen?&nbsp;</p> <p></p> </blockquote> <p></p> <p>&nbsp;</p> <p>Hi Matt,</p> <p>Ignore my previous response. I am experiencing the same problem as you with the Futures WebPartManager. The workaround works in Firefox but fails after the first async postback in IE. This proves that the inline dynamic script being emitted from the Futures WebPartManager is differant to that of the standard webpartmanager :(...</p> <p>The only solution then is to reverse engeneer this script this&nbsp;Manager is producing&nbsp;and update&nbsp;the Script Property on the WebPartManager also.</p> 2007-03-21T05:48:05-04:001630804http://forums.asp.net/p/1087200/1630804.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel Any clues as to how I could reverse engineer the WebPartManager?&nbsp; I would really love to have this functionality.<br> 2007-03-21T19:43:36-04:001630916http://forums.asp.net/p/1087200/1630916.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <blockquote><span class="icon-blockquote"></span> <h4>davior</h4> <p>Hi All,</p> <p>Some of you will be pleased to know that I have produced a workaround to address the issue of WebPart Drag and Drop (and verb popup menus) not operating correctly inside of an update panel. </p> <p><font size="2">Enjoy! [:D]</p> <p>David</font></p> <p></p> </blockquote> <p></p> <p>Hi David,<br> I have followed your instructions and my page works properly.<br> Unfortunately your solution does not work if I use my page with a masterpage.<br> It's a pity theat it does not work&nbsp;because your solution could be much profit for me in this moment. &nbsp;[:'(]</p> 2007-03-21T20:39:12-04:001631151http://forums.asp.net/p/1087200/1631151.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi All,</p> <p>I have&nbsp;made some changes to the work around so it uses the&nbsp;js file&nbsp;resource embeded in the System.Web assembly (instead of a copy of this file).</p> <p>I have also corrected some slight issues in the inline javascript (that may have caused script bugs in some circumstances). You can download the updated solution from the same place as before:</p> <p><font color="#7395c1"><a class="" title="Download the updated solution" href="https://www.ahsa.com.au/documentation/AJAX.Compatible.WebPartManager.zip" target="_blank"><strong>Download the&nbsp;Updated Solution</strong></a></font></p> <p><strong>Matt:</strong> for information on how to reverse engineer this component checkout, <strong><a class="" title="unbelievable, incredible program that every .NET developer should have!" href="http://www.aisto.com/roeder/dotnet/">Lutz Roeder's .NET Reflector</a></strong>. It's an awsome Disassembler program ;).</p> <p><strong>giuseppevitali:</strong> The changes I recently made to the project might just fix the issue you are having with Master pages (this was probably caused by the use of an incorrect client side id in the javascript being emitted). This should have been corrected by these changes.</p> <p>&nbsp;</p> 2007-03-21T23:58:03-04:001631796http://forums.asp.net/p/1087200/1631796.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Dear Davior</p> <p>thanks for the effort, i did everything you mentioned in your first post, but still the problem stayed with me i don't know what to do, i copied your solution,build it,&nbsp;added&nbsp;the reference(Sample.Web.UI.WebParts.dll) to it into my project and added the maping in the web.config but still i can't drag and drop web parts, i even made a small project and tried on it the same problem goes, and i don't know what is wrong.</p> <p>i know this is too much to ask, but&nbsp;can you place a sample downloadable&nbsp;project of how this is done, for further clarification, i would be very greatful, thanks in advance.</p> 2007-03-22T09:33:15-04:001633977http://forums.asp.net/p/1087200/1633977.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi,</p> <p>&nbsp;Thanks for this. Have you had a chance to have a look at the futures CTP with&nbsp;cross browser&nbsp;support? I quickly had a look but didn't manage to fix it. If you&nbsp;could have a look at it it would benefit the community tremendously!</p> <p>Again, many thanks!</p> <p>Manso</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>davior</h4> <p></p> <p>Hi All,</p> <p>I have&nbsp;made some changes to the work around so it uses the&nbsp;js file&nbsp;resource embeded in the System.Web assembly (instead of a copy of this file).</p> <p>I have also corrected some slight issues in the inline javascript (that may have caused script bugs in some circumstances). You can download the updated solution from the same place as before:</p> <p>...</p> </blockquote> 2007-03-23T13:12:40-04:001639786http://forums.asp.net/p/1087200/1639786.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi Davior:</p> <p>Your workaround work profectly on IE. But when i test it on FF it is not support well. Could take a look for this issue?</p> 2007-03-27T20:52:20-04:001644219http://forums.asp.net/p/1087200/1644219.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>FYI, we're planning to support WebParts inside an UpdatePanel in Orcas.</p> <p>-Mike</p> 2007-03-30T07:41:54-04:001651975http://forums.asp.net/p/1087200/1651975.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Alright ... So, I haven't been able to find a solution that works for both, but there is a solution that works on FF but not on IE.</p> <p>Instead of inheriting from System.Web.UI.WebControls.WebParts.WebPartManager and using the WebParts.js resource from it, use the Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager instead.</p> <p>So:</p> <pre class="prettyprint">public class WebPartManager : Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager { ... protected override void RegisterClientScript() { System.Web.UI.ScriptManager.RegisterClientScriptResource(this, typeof(Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager), &quot;WebParts.js&quot;); ... } }</pre>&nbsp; <p>One option might be to create two different controls that works for each and determine at runtime which browser is being used and add the correct WebPartManager. I'm sure there's a much more efficient way to get it to work for both in one control, but I'm not going to put a lot of time into it, so there you have it ...</p> 2007-04-04T19:44:32-04:001657836http://forums.asp.net/p/1087200/1657836.aspx/1?Re+Workaround+for+using+Web+Parts+with+AJAX+1+0+UpdatePanelRe: Workaround for using Web Parts with AJAX 1.0 UpdatePanel <p>Hi, </p> <p>Great post! </p> <p>I have one question how did you reach to the conclusion that WebPartManager is not loading the client scripts? What tools did you use to determine that? </p> <p><br> </p> <p>&nbsp;</p> 2007-04-09T19:29:00-04:00