I have created a CatalogPartChrome class and a CatalogZone to override the CreateCatalogPartChrome method and return my CatalogPartChrome class that will render the parts. I try two ways to override RenderCatalogPart.
Are there anyone could help me to fix this error, or any other suggestions about this way? thanks:)
Any suggestions are greately appreciated. My source code as bellow:
public override void RenderCatalogPart(HtmlTextWriter writer,
CatalogPart catalogPart)
{
//base.RenderCatalogPart(writer, catalogPart);
WebPartDescriptionCollection partDescriptions =
catalogPart.GetAvailableWebPartDescriptions();
#if
true
Panel panelContain = new Panel();
panelContain.ID =
"panelContainer";
panelContain.Width =
Unit.Pixel(250);
panelContain.BorderWidth =
Unit.Pixel(2);
panelContain.BorderStyle =
BorderStyle.Solid;
panelContain.BorderColor = System.Drawing.
Color.Black;
panelContain.BackColor = System.Drawing.
Color.Silver;
Panel panelPart;
foreach (WebPartDescription description in partDescriptions)
{
panelPart =
new Panel();
panelPart.ID =
"part" + description.ID.ToString();
panelPart.Attributes.Add(
"style", "width:100%; background-color:#FFF;text-align:left; cursor:move; font-weight:bold;");
Label lblPart = new Label();
lblPart.Text =
"Drag Me--" + description.Title;
lblPart.BackColor = System.Drawing.
Color.PowderBlue;
lblPart.Font.Size =
FontUnit.Small;
lblPart.BorderWidth =
Unit.Pixel(1);
lblPart.BorderStyle =
BorderStyle.Solid;
lblPart.Width =
Unit.Percentage(90);
lblPart.Height =
Unit.Pixel(20);
panelPart.Controls.Add(lblPart);
AjaxControlToolkit.
DragPanelExtender dragPanelExtender = new AjaxControlToolkit.DragPanelExtender();
dragPanelExtender.Page = (System.Web.UI.
Page)System.Web.HttpContext.Current.Handler;
dragPanelExtender.Enabled =
true;
dragPanelExtender.DragHandleID = panelPart.ID;
dragPanelExtender.TargetControlID = panelContain.ID;
panelPart.Controls.Add(dragPanelExtender);
panelContainer.Controls.Add(panelPart);
}
panelContainer.RenderControl(writer);
#endif
#if
false
WebPartZone webpartzone1 = new WebPartZone();
WebPartManager manager1 = WebPartManager.GetCurrentWebPartManager((System.Web.UI.Page)System.Web.HttpContext.Current.Handler);
//((System.Web.UI.Page)System.Web.HttpContext.Current.Handler).Controls.Add(webpartzone1);
int i = 0;
foreach (WebPartDescription description in partDescriptions)
{
WebPartIcon part = new WebPartIcon();
part.Title = description.Title;
manager1.AddWebPart(part, webpartzone1, i);
//manager1.MoveWebPart(part, webpartzone1, i);
i++;
}
writer.Write("<div style='padding-bottom:20px;color:#5377A9;font-family:Arial, Sans-Serif; font-weight:bold;font-size:0.8em;'>Drag part<div>");
webpartzone1.RenderControl(writer);
#endif
}