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.
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; }