hello guys.
this is INCREDIBLE!
ok, let me start by explaining the scenario:
1. page has 2 main areas: login and web zones
2. initially, the login is visible and the divs are hidden
3. during the load event, the displaymode property of the scriptmanager is set to designdisplaymode (only if the current user is authenticated)
4. the web parts controls (all of them) are inside an updatepanel
one aditional note: the login is done using the authenticationservice and this causes a click over a hidden button which is placed inside the updatepanel so that the page is partially refreshed.
ok, now the problem is that after loging in, i still wasn't able to drag-n-drop the webparts. if i refreshed the page, then everything was ok. so i started investigating and found the problem.
the problem is that when the webpartmanager is in designmode, it injects a hidden div element on the page. unfortunatelly it does this ny using a real bad approach (this is just my opinion): it mixes it with the client script code and everything is injected with the registerXXX api. as a result, the partial postback receives this as a reply for an update:
..previous content removed
<script type="text/javascript">
<!--
document.getElementById('aut').style.display = 'none';var __wpmExportWarning='This Web Part Page has been personalized. As a result, one or more Web Part properties may contain confidential information. Make sure the properties contain information that is safe for others to read. After exporting this Web Part, view properties in the Web Part description file (.WebPart) by using a text editor such as Microsoft Notepad.';var __wpmCloseProviderWarning='You are about to close this Web Part. It is currently providing data to other Web Parts, and these connections will be deleted if this Web Part is closed. To close this Web Part, click OK. To keep this Web Part, click Cancel.';var __wpmDeleteWarning='You are about to permanently delete this Web Part. Are you sure you want to do this? To delete this Web Part, click OK. To keep this Web Part, click Cancel.';// -->
</script>
<div id="manager___Drag" style="display:none; position:absolute; z-index: 32000; filter:alpha(opacity=75)"></div>
<script type="text/javascript">
__wpm = new WebPartManager();
__wpm.overlayContainerElement = document.getElementById('manager___Drag');
__wpm.personalizationScopeShared = false;
var zoneElement;
var zoneObject;
...more content follows
this is just an excerpt...note the line in bold...this is placed outside the panelcontent element and due to this isn't inserted on the page. as a result, you just can't user web parts in this scenarios...if you don't believe me, then use reflector and see the contents of the method registerclientscript:
protected virtual void RegisterClientScript()
{
this.Page.ClientScript.RegisterClientScriptResource(typeof(WebPartManager), "WebParts.js");
bool flag1 = this.DisplayMode.AllowPageDesign;
string text1 = string.Empty;
string text2 = "null";
if (flag1)
{
text1 = string.Format(CultureInfo.InvariantCulture, "\r\n<div id=\"{0}___Drag\" style=\"display:none; position:absolute; z-index: 32000; filter:alpha(opacity=75)\"></div>", new object[] { this.ClientID });
text2 = "document.getElementById('" + this.ClientID + "___Drag')";
}
StringBuilder builder1 = new StringBuilder(0x400);
foreach (WebPartZoneBase base1 in this._webPartZones)
{
string text3 = (base1.LayoutOrientation == Orientation.Vertical) ? "true" : "false";
string text4 = "false";
string text5 = "black";
if (flag1 && base1.AllowLayoutChange)
{
text4 = "true";
text5 = ColorTranslator.ToHtml(base1.DragHighlightColor);
}
builder1.AppendFormat("\r\nzoneElement = document.getElementById('{0}');\r\nif (zoneElement != null) {{\r\n zoneObject = __wpm.AddZone(zoneElement, '{1}', {2}, {3}, '{4}');", new object[] { base1.ClientID, base1.UniqueID, text3, text4, text5 });
WebPartCollection collection1 = this.GetWebPartsForZone(base1);
foreach (WebPart part1 in collection1)
{
string text6 = "null";
string text7 = "false";
if (flag1)
{
text6 = "document.getElementById('" + part1.TitleBarID + "')";
if (part1.AllowZoneChange)
{
text7 = "true";
}
}
builder1.AppendFormat("\r\n zoneObject.AddWebPart(document.getElementById('{0}'), {1}, {2});", part1.WholePartID, text6, text7);
}
builder1.Append("\r\n}");
}
string text8 = string.Format(CultureInfo.InvariantCulture, "\r\n{0}\r\n<script type=\"text/javascript\">\r\n\r\n__wpm = new WebPartManager();\r\n__wpm.overlayContainerElement = {1};\r\n__wpm.personalizationScopeShared = {2};\r\n\r\nvar zoneElement;\r\nvar zoneObject;\r\n{3}\r\n</script>\r\n", new object[] { text1, text2, (this.Personalization.Scope == PersonalizationScope.Shared) ? "true" : "false", builder1.ToString() });
this.Page.ClientScript.RegisterStartupScript(typeof(WebPartManager), string.Empty, text8);
}
i think i can say that this is really some "exotic" code. so, when will you fix this?
thanks.