i tried what u told but still the verbs are not visible after i change the verb. i am using Microsoft ASP.NET 2.0 AJAX Extensions. Please help me get over this.
Great post. I have tried the solution and it seems to be working fine EXCEPT one issue. If Iclose the browser after customising the page , the changes will be lost. That is the page is getting reset to intial state on each visit. Has anyone else experienced
the same issue? Any ideas ??
I found one issue with the code from above, which required one modification. It occurs when you set the PartChromeType of a WebPartZone to "None". The script property attempts to create the a menu and appropriate CSS classes for the menuItemLabel object.
With PartChromeType set to none there is no label and you will get javascript errors.
The change is to make sure an element exists before attempting to set its attributes, startting at line 92.
Thanks for the information. It worked nicely in IE. My drag-and-drop still wasn't working in Firefox and Opera though.
After some testing I found out that in Firefox / Opera the RegisterClientScript() method of my custom webpartmanager somehow wasn't being called at all. I fixed this by adding:
public void InitScript()
{
this.RegisterClientScript();
}
to my custom webpartmanager and calling this method in the page_load of my codebehind.
Im using the ASPNET FUTURES Webparts for me to enable drag and drop capability in firefox because STANDARD Webparts drag and drop capability will not work properly in firefox. My problem of using the ASPNET Futures is that if I placed webparts within Update
panel control it would not work the drag and drop capabilty. Is there any other work arround on how to enable the drag and drop capability of aspnet future webparts inside the update panel control? I would be more thankful of you would reply and shed light
regarding thi matter....[:)]
The current version of the AJAX Futures has a bug when using WebParts inside an UpdatePanel. We are investigating and this will be fixed in a later release of the AJAX Futures. Thanks.
email.inscri...
Member
82 Points
17 Posts
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Apr 12, 2007 03:25 PM|LINK
The same code in c# would be the following [8-|]
using System.Web; using System.Web.UI.WebControls.WebParts; namespace MyControls { [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] public class MyWebPartManager : WebPartManager { protected override void RegisterClientScript() { if (this.CheckRenderClientScript()) { // System.Web.UI.ScriptManager is localized in the reference System.Web.Extensions System.Web.UI.ScriptManager.RegisterClientScriptResource( this, typeof(WebPartManager), "WebParts.js"); System.Web.UI.ScriptManager.RegisterStartupScript( this, this.GetType(), this.ID + "_Script", this.Script, true); } } protected override void Render(System.Web.UI.HtmlTextWriter writer) { base.Render(writer); System.Web.UI.WebControls.Panel dragPanel = new System.Web.UI.WebControls.Panel(); dragPanel.ID = string.Format("{0}___Drag", this.ClientID); dragPanel.Style.Add("display", "none"); dragPanel.Style.Add("position", "absolute"); dragPanel.Style.Add("z-index", "32000"); dragPanel.Style.Add("filter", "alpha(opacity=75)"); dragPanel.RenderControl(writer); } /// <summary> /// Property related to the client side scripts /// </summary> private string Script { get { System.Web.UI.WebControls.WebColorConverter colorConverter = new System.Web.UI.WebControls.WebColorConverter(); string _clientScript = string.Format( "__wpm = new WebPartManager();{0}" + "__wpm.overlayContainerElement = document.getElementById('{2}___Drag');{0}" + "__wpm.personalizationScopeShared = {1};{0}" + "var zoneElement;{0}var zoneObject;{0}", System.Environment.NewLine, this.Personalization.CanEnterSharedScope.ToString().ToLower(), this.ClientID); foreach (WebPartZone z in this.Zones) { bool verticalOrientation = (z.LayoutOrientation == System.Web.UI.WebControls.Orientation.Vertical); bool allowLayoutChange = this.DisplayMode.Name != WebPartManager.BrowseDisplayMode.Name && z.AllowLayoutChange; string dragHighlightColor = colorConverter.ConvertToString(z.DragHighlightColor); _clientScript += string.Format( "zoneElement = document.getElementById('{1}');if (zoneElement != null) {{zoneObject = __wpm.AddZone(zoneElement, '{2}', {3}, {4}, '{5}');{0}", System.Environment.NewLine, z.ClientID, z.UniqueID, verticalOrientation.ToString().ToLower(), allowLayoutChange.ToString().ToLower(), dragHighlightColor); foreach (WebPart p in z.WebParts) { bool allowZoneChange = allowLayoutChange && p.AllowZoneChange; _clientScript += string.Format( " zoneObject.AddWebPart(document.getElementById('WebPart_{1}'), document.getElementById('WebPartTitle_{1}'), {2});{0}", System.Environment.NewLine, p.ID, allowZoneChange.ToString().ToLower()); } _clientScript += "}"; } foreach (WebPartZone z in this.Zones) { string itemStyle = z.MenuVerbStyle.GetStyleAttributes(null).Value; string itemHoverStyle = z.MenuVerbHoverStyle.GetStyleAttributes(null).Value; string labelHoverColor = colorConverter.ConvertToString(z.MenuLabelHoverStyle.ForeColor); if (z.WebPartVerbRenderMode == WebPartVerbRenderMode.Menu) { foreach (WebPart p in z.WebParts) { string verbMenuScript = string.Format( "var menuWebPart_{0}Verbs = new WebPartMenu(document.getElementById('WebPart_{0}Verbs'), document.getElementById('WebPart_{0}VerbsPopup'), document.getElementById('WebPart_{0}VerbsMenu'));{1}" + "menuWebPart_{0}Verbs.itemStyle = '{3};';{1}" + "menuWebPart_{0}Verbs.itemHoverStyle = '{4}';{1}" + "menuWebPart_{0}Verbs.labelHoverColor = '{5}';{1}" + "menuWebPart_{0}Verbs.labelHoverClassName = '{2}__Menu_1';{1}{1}", p.ID, System.Environment.NewLine, z.ID, itemStyle, itemHoverStyle, labelHoverColor); _clientScript += verbMenuScript; } } } return _clientScript; } } } }sajberek
Member
9 Points
3 Posts
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
May 16, 2007 11:47 AM|LINK
Make sure you put WebPartManager inside the updatePanel with your webPartZones.
nitinn
Member
2 Points
1 Post
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
May 18, 2007 06:26 AM|LINK
Hi,
i tried what u told but still the verbs are not visible after i change the verb. i am using Microsoft ASP.NET 2.0 AJAX Extensions. Please help me get over this.
junaidabidi
Member
6 Points
8 Posts
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
May 30, 2007 12:12 PM|LINK
Great post. I have tried the solution and it seems to be working fine EXCEPT one issue. If Iclose the browser after customising the page , the changes will be lost. That is the page is getting reset to intial state on each visit. Has anyone else experienced the same issue? Any ideas ??
BhaveshPatel
Member
353 Points
128 Posts
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Jun 08, 2007 09:23 PM|LINK
Hey guys... whoever did it... really great job... appreciate it......
for junaidabidi .. it may be happening because you may be adding web part dynamically. If so then follow this.
add this function public void SetDirty(){
SetPersonalizationDirty();
}
TO webpartmanager class.
and whenever you are adding webpart dynamically add this line in your code behind.
WebPartManager1.SetDirty();
Hope this helps.
Bhavesh Patel
blisted
Member
2 Points
1 Post
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Aug 15, 2007 06:30 PM|LINK
I found one issue with the code from above, which required one modification. It occurs when you set the PartChromeType of a WebPartZone to "None". The script property attempts to create the a menu and appropriate CSS classes for the menuItemLabel object. With PartChromeType set to none there is no label and you will get javascript errors.
The change is to make sure an element exists before attempting to set its attributes, startting at line 92.
foreach (WebPart p in z.WebParts) { string verbMenuScript = string.Format( "var menuItemLabel = document.getElementById('WebPart_{0}Verbs');{1}" + "if( menuItemLabel != null ) {{ {1}" + "var menuWebPart_{0}Verbs = new WebPartMenu(menuItemLabel, document.getElementById('WebPart_{0}VerbsPopup'), document.getElementById('WebPart_{0}VerbsMenu'));{1}" + "menuWebPart_{0}Verbs.itemStyle = '{3};';{1}" + "menuWebPart_{0}Verbs.itemHoverStyle = '{4}';{1}" + "menuWebPart_{0}Verbs.labelHoverColor = '{5}';{1}" + "menuWebPart_{0}Verbs.labelHoverClassName = '{2}__Menu_1';{1}" + "}} {1}", p.ID, System.Environment.NewLine, z.ID, itemStyle, itemHoverStyle, labelHoverColor); _clientScript += verbMenuScript; }Rob82
Member
44 Points
16 Posts
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Sep 19, 2007 01:01 PM|LINK
Thanks for the information. It worked nicely in IE. My drag-and-drop still wasn't working in Firefox and Opera though.
After some testing I found out that in Firefox / Opera the RegisterClientScript() method of my custom webpartmanager somehow wasn't being called at all. I fixed this by adding:
public void InitScript() { this.RegisterClientScript(); }to my custom webpartmanager and calling this method in the page_load of my codebehind.vinz
All-Star
126896 Points
17922 Posts
MVP
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Oct 05, 2007 03:56 PM|LINK
Hi david,
Im using the ASPNET FUTURES Webparts for me to enable drag and drop capability in firefox because STANDARD Webparts drag and drop capability will not work properly in firefox. My problem of using the ASPNET Futures is that if I placed webparts within Update panel control it would not work the drag and drop capabilty. Is there any other work arround on how to enable the drag and drop capability of aspnet future webparts inside the update panel control? I would be more thankful of you would reply and shed light regarding thi matter....[:)]
Thanks,
Maverick
MessageBox Controls for WebForms | Blog | Twitter | Linkedin
mharder
Contributor
4567 Points
917 Posts
Microsoft
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Oct 05, 2007 09:40 PM|LINK
The current version of the AJAX Futures has a bug when using WebParts inside an UpdatePanel. We are investigating and this will be fixed in a later release of the AJAX Futures. Thanks.
-Mike
This posting is provided "AS IS" with no warranties, and confers no rights.
rami6000
Member
2 Points
1 Post
Re: Workaround for using Web Parts with AJAX 1.0 UpdatePanel
Oct 31, 2007 03:00 PM|LINK
So when will the new Futures/release going to happen? Any ideas?
Using the ASP.Net 2.0 Webpart framework is rather useless with the entire page refreshing.