Ejemplo n.º 1
0
        private void FindWebSiteParts(HtmlTextWriter writer, Microsoft.SharePoint.WebPartPages.WebPartZone zone)
        {
            for (int i = 0; i < zone.WebParts.Count; i++)
            {
                System.Web.UI.WebControls.WebParts.WebPart webpart = zone.WebParts[i];

                if (webpart.GetType() == typeof(WebSitePart))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSitePart");
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    zone.WebParts[i].RenderControl(writer);
                    writer.RenderEndTag();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates the target-specific markup for the control to which the control adapter is attached.
        /// </summary>
        /// <param name="writer">The <see cref="HtmlTextWriter"/> to use to render the target-specific output.</param>
        protected override void Render(HtmlTextWriter writer)
        {
            zone = Control as Microsoft.SharePoint.WebPartPages.WebPartZone;

            // if not edit mode, change each table to a div; otherwise, add summary to each table
            if (!IsEditMode(Page))
            {
                if (zone != null && (zone.ID.ToLower() != "main" && zone.ID.ToLower() != "wpz"))
                {
                    RenderWithDiv(writer, zone);
                }
                else
                {
                    base.Render(writer);
                }
            }
            else
            {
                // get html from original control
                StringBuilder builder = new StringBuilder();
                using (var baseWriter = new HtmlTextWriter(new StringWriter(builder, CultureInfo.InvariantCulture)))
                {
                    //FindWebSiteParts(baseWriter, zone);
                    base.Render(baseWriter);

                    //RenderAddWebPartZoneCell(baseWriter);
                }


                string output = builder.ToString();
                if (zone != null && (zone.ID.ToLower() != "main" && zone.ID.ToLower() != "wpz"))
                {
                    output = AddZoneTitleSummary(output);
                    output = RemoveHrefWebPart(output);
                    output = RemoveWebpartMenu(output);
                    output = RemoveWebpartSelection(output);
                }
                //output = CreateAddWebPartScript(output);
                // render base html with summary attribute added to the zone title table
                //output = AddZoneTitleSummary(output);


                writer.Write(output);
            }
        }