Beispiel #1
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            var i  = 0;

            foreach (var percent in WidgetManager.GetColumnSchemaPercents(columnSchemaType))
            {
                sb.Append("<ul id='widgetCol_" + widgetContainerId + "_" + i + "' name='" + i + "' " + (i == 0 ? "class=\"studioFirstColunm\"" : "") + " style=\"list-style-type: none; padding:0px 0px 5px 0px; margin:0; float:left;  width:" + percent + "%;\" >");
                foreach (var control in Controls)
                {
                    var widget = control as Widget;
                    if (widget == null || widget.WidgetState.X != i)
                    {
                        continue;
                    }
                    writer.Write(sb.ToString());
                    using (var stringWriter = new StringWriter())
                    {
                        using (var tempWriter = new HtmlTextWriter(stringWriter))
                            try
                            {
                                //NOTE: we do such thing to avoid writing unnesesary elements to output
                                widget.RenderControl(tempWriter);
                                writer.Write(stringWriter.GetStringBuilder().ToString());
                            }
                            catch (Exception e)
                            {
                                var broken = Page.LoadControl(BrokenWidget.Path) as BrokenWidget;
                                widget.RenderBeginTag(writer);
                                if (broken != null)
                                {
                                    broken.Exception = e;
                                    broken.RenderControl(writer);
                                }
                                widget.RenderEndTag(writer);
                            }
                    }
                    sb = new StringBuilder();
                }

                sb.Append("</ul>");
                i++;
            }
            writer.Write(sb.ToString());
        }