RenderControl() public method

Outputs server control content to a provided T:System.Web.UI.HtmlTextWriter object and stores tracing information about the control if tracing is enabled.
public RenderControl ( System.Web.UI.HtmlTextWriter writer ) : void
writer System.Web.UI.HtmlTextWriter The object that receives the control content.
return void
Beispiel #1
0
        /// <summary>
        /// Writes the <see cref="T:System.Web.UI.WebControls.CompositeControl" /> content to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object, for display on the client.
        /// </summary>
        /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            if (!string.IsNullOrEmpty(PreHtml))
            {
                writer.Write(PreHtml);
            }

            DataFilterComponent component = null;
            string clientFormatString     = string.Empty;

            if (!string.IsNullOrWhiteSpace(FilterEntityTypeName))
            {
                component = Rock.Reporting.DataFilterContainer.GetComponent(FilterEntityTypeName);
                if (component != null)
                {
                    clientFormatString =
                        string.Format("if ($(this).find('.filter-view-state').children('i').hasClass('fa-chevron-up')) {{ var $article = $(this).parents('article').first(); var $content = $article.children('div.panel-body'); $article.find('div.filter-item-description').first().html({0}); }}", component.GetClientFormatSelection(FilteredEntityType));
                }
            }

            if (component == null || HasFilterError)
            {
                writer.Write("<a name='filtererror'></a>");
                hfExpanded.Value = "True";
            }

            bool showFilterTypePicker = this.FilterMode == FilterMode.AdvancedFilter;

            if (showFilterTypePicker)
            {
                // only render this stuff if the filter type picker is shown
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel panel-widget filter-item");

                writer.RenderBeginTag("article");

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel-heading clearfix");
                if (!string.IsNullOrEmpty(clientFormatString))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, clientFormatString);
                }

                writer.RenderBeginTag("header");

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-expanded");
                hfExpanded.RenderControl(writer);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-left");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-description");
                if (Expanded)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                string filterHeaderSelectionHtml;
                if (HasFilterError)
                {
                    filterHeaderSelectionHtml = "<span class='label label-danger'>Filter has an error</span>";
                }
                else if (component != null)
                {
                    filterHeaderSelectionHtml = component.FormatSelection(FilteredEntityType, this.GetSelection());
                }
                else
                {
                    filterHeaderSelectionHtml = "Select Filter";
                }

                writer.Write(filterHeaderSelectionHtml);
                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-select");
                if (!Expanded)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write("Filter Type ");
                writer.RenderEndTag();

                ddlFilterType.RenderControl(writer);
                writer.RenderEndTag();

                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-right");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn btn-link btn-xs filter-view-state");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, Expanded ? "fa fa-chevron-up" : "fa fa-chevron-down");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.Write(" ");
                lbDelete.Visible = (this.DeleteClick != null);
                lbDelete.RenderControl(writer);
                writer.RenderEndTag();

                writer.RenderEndTag();

                writer.AddAttribute("class", "panel-body");
                if (!Expanded)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
            }

            writer.AddAttribute("class", "row js-filter-row filterfield");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.AddAttribute("class", "col-md-12");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (ShowCheckbox)
            {
                //// EntityFieldFilter renders the checkbox itself (see EntityFieldFilter.cs),
                //// so only render the checkbox if we are hiding filter criteria and it isn't an entity field filter
                if (!(component is Rock.Reporting.DataFilter.EntityFieldFilter) || HideFilterCriteria)
                {
                    cbIncludeFilter.Text = this.Label;
                    cbIncludeFilter.RenderControl(writer);
                }
            }
            else if (!string.IsNullOrWhiteSpace(this.Label))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
                writer.AddAttribute(HtmlTextWriterAttribute.For, this.ClientID);
                writer.RenderBeginTag(HtmlTextWriterTag.Label);
                writer.Write(Label);
                writer.RenderEndTag();  // label
            }

            if (HasFilterError)
            {
                nbFilterError.RenderControl(writer);
            }

            if (component != null && !HideFilterCriteria)
            {
                if (!string.IsNullOrEmpty(component.Description) && !HideDescription)
                {
                    nbComponentDescription.Text     = component.Description;
                    nbComponentDescription.CssClass = "filter-field-description";
                    nbComponentDescription.RenderControl(writer);
                }

                component.RenderControls(FilteredEntityType, this, writer, filterControls, this.FilterMode);
            }

            writer.RenderEndTag(); // "col-md-12"
            writer.RenderEndTag(); // "row js-filter-row filter-row"

            if (showFilterTypePicker)
            {
                writer.RenderEndTag();

                writer.RenderEndTag();
            }

            if (!string.IsNullOrEmpty(PostHtml))
            {
                writer.Write(PostHtml);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This is where you implement the simple aspects of rendering your control.  The rest
        /// will be handled by calling RenderControlHelper's RenderControl() method.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public void RenderBaseControl(HtmlTextWriter writer)
        {
            _nbErrorMessage.RenderControl(writer);
            writer.AddAttribute("id", this.ClientID);
            writer.AddAttribute("class", "image-editor-group imageupload-group");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute("class", "image-editor-photo");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.Write(@"
                <div class='js-upload-progress' style='display:none'>
                    <i class='fa fa-refresh fa-3x fa-spin'></i>
                </div>");

            string backgroundImageFormat = "<div class='image-container' id='{0}' style='background-image:url({1});background-size:cover;background-position:50%'></div>";
            string imageDivHtml          = "";

            if (BinaryFileId != null)
            {
                imageDivHtml = string.Format(backgroundImageFormat, this.ClientID + "_divPhoto", this.ResolveUrl("~/GetImage.ashx?id=" + BinaryFileId.ToString() + "&width=150"));
            }
            else
            {
                imageDivHtml = string.Format(backgroundImageFormat, this.ClientID + "_divPhoto", this.NoPictureUrl);
            }

            writer.Write(imageDivHtml);
            writer.WriteLine();

            if (string.IsNullOrEmpty(ButtonCssClass))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "options");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            // We only show the Modal/Editor if the delete button is enabled and
            // we have a file already.
            if (ShowDeleteButton && (BinaryFileId ?? 0) > 0)
            {
                _lbShowModal.Style[HtmlTextWriterStyle.Display]   = string.Empty;
                _lbUploadImage.Style[HtmlTextWriterStyle.Display] = "none";
            }
            else
            {
                _lbShowModal.Style[HtmlTextWriterStyle.Display]   = "none";
                _lbUploadImage.Style[HtmlTextWriterStyle.Display] = string.Empty;
            }

            _lbShowModal.RenderControl(writer);
            _lbUploadImage.Text     = this.ButtonText;
            _lbUploadImage.CssClass = this.ButtonCssClass;
            _lbUploadImage.Attributes["onclick"] = "return false;";
            _lbUploadImage.RenderControl(writer);

            // render the circle check status for when save happens
            writer.WriteLine();
            _lSaveStatus.RenderControl(writer);

            // Don't render the _aRemove control if there is no BinaryFile to remove.
            if (BinaryFileId != null)
            {
                writer.WriteLine();
                _aRemove.RenderControl(writer);
            }

            writer.WriteLine();
            writer.RenderEndTag();
            writer.WriteLine();

            _hfBinaryFileId.RenderControl(writer);
            writer.WriteLine();
            _hfOriginalBinaryFileId.RenderControl(writer);
            writer.WriteLine();
            _hfCropBinaryFileId.RenderControl(writer);
            writer.WriteLine();
            _hfBinaryFileTypeGuid.RenderControl(writer);
            writer.WriteLine();

            writer.AddAttribute("class", "image-editor-fileinput");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            _fileUpload.Attributes["name"] = string.Format("{0}[]", this.ID);
            _fileUpload.RenderControl(writer);
            writer.RenderEndTag();
            writer.WriteLine();

            writer.RenderEndTag(); // image-editor-photo
            writer.WriteLine();

            writer.RenderEndTag(); // image-editor-group

            _mdImageDialog.RenderControl(writer);

            RegisterStartupScript();
        }
Beispiel #3
0
        /// <summary>
        /// Outputs server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object and stores tracing information about the control if tracing is enabled.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the control content.</param>
        public override void RenderControl( System.Web.UI.HtmlTextWriter writer )
        {
            List<string> widgetCssList = GetDivWidthCssClasses();

            writer.AddAttribute( System.Web.UI.HtmlTextWriterAttribute.Class, widgetCssList.AsDelimited( " " ) );
            writer.RenderBeginTag( System.Web.UI.HtmlTextWriterTag.Div );

            writer.AddAttribute( System.Web.UI.HtmlTextWriterAttribute.Class, "panel-dashboard" );
            writer.RenderBeginTag( System.Web.UI.HtmlTextWriterTag.Div );

            writer.AddAttribute( System.Web.UI.HtmlTextWriterAttribute.Class, "panel-body" );
            writer.RenderBeginTag( System.Web.UI.HtmlTextWriterTag.Div );

            if ( !string.IsNullOrWhiteSpace( WidgetErrorMessage ) )
            {
                var errorBox = new NotificationBox { ID = "nbWidgetError", NotificationBoxType = NotificationBoxType.Danger, Text = WidgetErrorMessage, Title = "Error", Dismissable = true, Details = WidgetErrorDetails };
                errorBox.RenderControl( writer );
            }

            base.RenderControl( writer );

            writer.RenderEndTag();

            writer.RenderEndTag();

            writer.RenderEndTag();
        }