当前位置: 首页>>代码示例>>C#>>正文


C# PlaceHolder.RenderControl方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.PlaceHolder.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# PlaceHolder.RenderControl方法的具体用法?C# PlaceHolder.RenderControl怎么用?C# PlaceHolder.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.PlaceHolder的用法示例。


在下文中一共展示了PlaceHolder.RenderControl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildItem

        /// <remarks>
        /// Applied CodePlex patch #337/338 provided by tonyhild to apply the <c>AspNet-DetailsView-RowCommand</c> class to the
        /// list item row for command buttons.
        /// </remarks>
        protected override void BuildItem(HtmlTextWriter writer)
        {
            if (IsDetailsView && (ControlAsDetailsView.Rows.Count > 0))
            {
                writer.WriteLine();
                writer.WriteBeginTag("div");
                writer.WriteAttribute("class", _classData);
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;

                // Check for empty data set
                // If no data is provided, render EmptyDataTemplate or EmptyDataText
                if (ControlAsDetailsView.DataItemCount == 0 && ControlAsDetailsView.CurrentMode != DetailsViewMode.Insert)
                {
                    writer.WriteBeginTag("div");
                    writer.WriteAttribute("class", _classEmptyData);
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Indent++;

                    PlaceHolder placeholder = new PlaceHolder();

                    // render EmptyDataTemplate or EmptyDataText
                    if (ControlAsDetailsView.EmptyDataTemplate != null)
                    {
                        ControlAsDetailsView.EmptyDataTemplate.InstantiateIn(placeholder);
                    }
                    else
                    {
                        Literal emptydatatext = new Literal();
                        emptydatatext.Text = ControlAsDetailsView.EmptyDataText;
                        placeholder.Controls.Add(emptydatatext);
                    }

                    placeholder.RenderControl(writer);

                    writer.Indent--;
                    writer.WriteLine();
                    writer.WriteEndTag("div");
                }
                else
                {
                    // render normally
                    writer.WriteLine();
                    writer.WriteBeginTag("ul");
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Indent++;

                    bool useFields = (!ControlAsDetailsView.AutoGenerateRows) && (ControlAsDetailsView.Fields.Count == ControlAsDetailsView.Rows.Count);
                    int countRenderedRows = 0;
                    for (int iRow = 0; iRow < ControlAsDetailsView.Rows.Count; iRow++)
                    {
                        if ((!useFields) || (useFields && ControlAsDetailsView.Fields[iRow].Visible) && ControlAsDetailsView.Rows[iRow].Visible)
                        {
                            DetailsViewRow row = ControlAsDetailsView.Rows[iRow];
                            if ((!ControlAsDetailsView.AutoGenerateRows) &&
                                    ((row.RowState & DataControlRowState.Insert) == DataControlRowState.Insert) &&
                                    (iRow < ControlAsDetailsView.Fields.Count) &&
                                    (!ControlAsDetailsView.Fields[row.RowIndex].InsertVisible))
                            {
                                continue;
                            }

                            writer.WriteLine();
                            writer.WriteBeginTag("li");
                            bool isRowCommand = (row.Cells[0] as DataControlFieldCell).ContainingField is ButtonFieldBase;
                            string theClass = string.Empty;
                            if (isRowCommand)
                            {
                                theClass = "AspNet-DetailsView-RowCommand";
                            }
                            else
                            {
                                theClass = ((countRenderedRows % 2) == 1) ? "AspNet-DetailsView-Alternate" : "";
                            }
                            if (useFields && (ControlAsDetailsView.Fields[iRow].ItemStyle != null) && (!String.IsNullOrEmpty(ControlAsDetailsView.Fields[iRow].ItemStyle.CssClass)))
                            {
                                if (!String.IsNullOrEmpty(theClass))
                                {
                                    theClass += " ";
                                }
                                theClass += ControlAsDetailsView.Fields[iRow].ItemStyle.CssClass;
                            }
                            if (!String.IsNullOrEmpty(theClass))
                            {
                                writer.WriteAttribute("class", theClass);
                            }
                            writer.Write(HtmlTextWriter.TagRightChar);
                            writer.Indent++;
                            writer.WriteLine();

                            for (int iCell = 0; iCell < row.Cells.Count; iCell++)
                            {
                                TableCell cell = row.Cells[iCell];
                                if (!isRowCommand)
                                {
                                    writer.WriteBeginTag("span");
//.........这里部分代码省略.........
开发者ID:skt90u,项目名称:skt90u-framework-dotnet,代码行数:101,代码来源:DetailsViewAdapter.cs

示例2: BuildItem

        protected override void BuildItem(HtmlTextWriter writer)
        {
            if ((ControlAsFormView.Row != null) &&
                (ControlAsFormView.Row.Cells.Count > 0))
            {
                writer.WriteLine();
                writer.WriteBeginTag("div");
                writer.WriteAttribute("class", _classData);
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;
                writer.WriteLine();

                switch (ControlAsFormView.CurrentMode)
                {
                    case FormViewMode.Insert:
                        writer.WriteBeginTag("div");
                        writer.WriteAttribute("class", _classInsertData);
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        foreach (Control itemCtrl in ControlAsFormView.Row.Cells[0].Controls)
                        {
                            itemCtrl.RenderControl(writer);
                        }

                        writer.Indent--;
                        writer.WriteLine();
                        writer.WriteEndTag("div");
                        break;

                    default:
                        if (DataItemCount == 0)
                        {
                            writer.WriteBeginTag("div");
                            writer.WriteAttribute("class", _classEmptyData);
                            writer.Write(HtmlTextWriter.TagRightChar);
                            writer.Indent++;

                            if (ControlAsFormView.EmptyDataTemplate != null)
                            {
                                PlaceHolder placeholder = new PlaceHolder();
                                ControlAsFormView.Controls.Add(placeholder);
                                ControlAsFormView.EmptyDataTemplate.InstantiateIn(placeholder);
                                placeholder.RenderControl(writer);
                            }
                            else
                            {
                                writer.Write(ControlAsFormView.EmptyDataText);
                            }

                            writer.Indent--;
                            writer.WriteLine();
                            writer.WriteEndTag("div");
                        }
                        else
                        {
                            foreach (Control itemCtrl in ControlAsFormView.Row.Cells[0].Controls)
                            {
                                itemCtrl.RenderControl(writer);
                            }
                        }

                        break;
                }
                writer.Indent--;
                writer.WriteLine();
                writer.WriteEndTag("div");
            }
        }
开发者ID:skt90u,项目名称:skt90u-framework-dotnet,代码行数:69,代码来源:FormViewAdapter.cs

示例3: WriteOutData

		public virtual void WriteOutData(HtmlTextWriter writer) {
			rpPagedContents.EnableViewState = this.EnableViewState;
			rpPager.EnableViewState = true;

			List<object> lstContents = new List<object>();

			int iTotalPages = 0;

			this.Controls.Add(rpPagedContents);
			this.Controls.Add(rpPager);

			rpPagedContents.DataSource = this.DataSource;
			rpPagedContents.DataBind();

			iTotalPages = this.TotalRecords / this.PageSize;

			if ((this.TotalRecords % this.PageSize) > 0) {
				iTotalPages++;
			}

			if (this.ShowPager && iTotalPages > 1) {
				List<int> pagelist = new List<int>();

				if (this.MaxPage > iTotalPages) {
					pagelist = Enumerable.Range(1, this.MaxPage).ToList();
				} else {
					pagelist = Enumerable.Range(1, iTotalPages).ToList();
				}

				rpPager.DataSource = pagelist;
				rpPager.DataBind();
			}

			WalkCtrlsForAssignment(rpPager);

			writer.Indent++;
			writer.Indent++;

			writer.WriteLine();

			if (!this.HideSpanWrapper) {
				writer.WriteLine("<span id=\"" + this.ClientID + "\">");
				writer.WriteLine();
			}

			if (PagerBelowContent) {
				RenderWrappedControl(writer, rpPagedContents, this.CSSPageListing);
				RenderWrappedControl(writer, rpPager, this.CSSPageFooter);
			} else {
				RenderWrappedControl(writer, rpPager, this.CSSPageFooter);
				RenderWrappedControl(writer, rpPagedContents, this.CSSPageListing);
			}

			if (this.TotalRecords <= 0) {
				PlaceHolder phEntry = new PlaceHolder();
				if (this.EmptyDataTemplate != null) {
					this.EmptyDataTemplate.InstantiateIn(phEntry);
				}

				this.Controls.Add(phEntry);
				phEntry.RenderControl(writer);
			}

			hdnPageNbr.RenderControl(writer);

			base.RenderContents(writer);

			writer.WriteLine();

			if (!this.HideSpanWrapper) {
				writer.WriteLine("</span>");
			}

			writer.Indent--;
			writer.Indent--;
		}
开发者ID:tridipkolkata,项目名称:CarrotCakeCMS,代码行数:76,代码来源:BasePagedDataTemplate.cs

示例4: BuildItem

        protected override void BuildItem(HtmlTextWriter writer)
        {
            if ((ControlAsFormView.Row != null) &&
                (ControlAsFormView.Row.Cells.Count > 0))
            {
                writer.WriteLine();
                writer.WriteBeginTag("div");
                writer.WriteAttribute("class", _classData);
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Indent++;
                writer.WriteLine();

                if (DataItemCount == 0)
                {
                    writer.WriteBeginTag("div");
                    writer.WriteAttribute("class", _classEmptyData);
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Indent++;

                    PlaceHolder placeholder = new PlaceHolder();

                    // render EmptyDataTemplate or EmptyDataText
                    if (ControlAsFormView.EmptyDataTemplate != null)
                    {
                        ControlAsFormView.EmptyDataTemplate.InstantiateIn(placeholder);
                    }
                    else
                    {
                        Literal emptydatatext = new Literal();
                        emptydatatext.Text = ControlAsFormView.EmptyDataText;
                        placeholder.Controls.Add(emptydatatext);
                    }
                    placeholder.RenderControl(writer);

                    writer.Indent--;
                    writer.WriteLine();
                    writer.WriteEndTag("div");
                }
                else // render contents only if NOT emptydata
                {
                    foreach (Control itemCtrl in ControlAsFormView.Row.Cells[0].Controls)
                    {
                        itemCtrl.RenderControl(writer);
                    }
                }
                writer.Indent--;
                writer.WriteLine();
                writer.WriteEndTag("div");
            }
        }
开发者ID:thaond,项目名称:vdms-sym-project,代码行数:50,代码来源:FormViewAdapter.cs

示例5: RenderContents

        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (Extender.AdapterEnabled)
            {
                DataList dataList = Control as DataList;
                int columns = (dataList.SeparatorTemplate == null ? RepeatColumns : RepeatColumns * 2);

                if (dataList != null)
                {
                    if (dataList.RepeatLayout == RepeatLayout.Table)
                    {
                    writer.Indent++;
                    writer.WriteLine();
                    writer.WriteBeginTag("table");
                    writer.WriteAttribute("cellpadding", dataList.CellPadding.ToString());
                    writer.WriteAttribute("cellspacing", dataList.CellSpacing.ToString());
                    writer.WriteAttribute("summary", Control.ToolTip);
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Indent++;

                    if (dataList.HeaderTemplate != null && dataList.ShowHeader)
                    {
                        if (!String.IsNullOrEmpty(dataList.Caption))
                        {
                            writer.WriteLine();
                            writer.WriteBeginTag("caption");
                            writer.Write(HtmlTextWriter.TagRightChar);
                            writer.Write(dataList.Caption);
                            writer.WriteEndTag("caption");
                        }

                        writer.WriteLine();
                        writer.WriteBeginTag("thead");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        writer.WriteLine();
                        writer.WriteBeginTag("tr");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        writer.WriteLine();
                        writer.WriteBeginTag("th");
                        writer.WriteAttribute("colspan", columns.ToString());
                        string className = "AspNet-DataList-Header ";
                        if (dataList.HeaderStyle != null)
                        {
                            className += dataList.HeaderStyle.CssClass;
                        }
                        writer.WriteAttribute("class", className);
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        PlaceHolder container = new PlaceHolder();
                        dataList.HeaderTemplate.InstantiateIn(container);
                        container.DataBind();
                        container.RenderControl(writer);

                        writer.Indent--;
                        writer.WriteLine();
                        writer.WriteEndTag("th");

                        writer.Indent--;
                        writer.WriteLine();
                        writer.WriteEndTag("tr");

                        writer.Indent--;
                        writer.WriteLine();
                        writer.WriteEndTag("thead");

                    }

                    if (dataList.FooterTemplate != null && dataList.ShowFooter)
                    {
                        writer.WriteLine();
                        writer.WriteBeginTag("tfoot");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        writer.WriteLine();
                        writer.WriteBeginTag("tr");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        writer.WriteLine();
                        writer.WriteBeginTag("td");
                        writer.WriteAttribute("colspan", columns.ToString());
                        string className = "AspNet-DataList-Footer ";
                        if (dataList.FooterStyle != null)
                        {
                            className += dataList.FooterStyle.CssClass;
                        }
                        writer.WriteAttribute("class", className);
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        PlaceHolder container = new PlaceHolder();
                        dataList.FooterTemplate.InstantiateIn(container);
                        container.DataBind();
                        container.RenderControl(writer);
//.........这里部分代码省略.........
开发者ID:skt90u,项目名称:skt90u-framework-dotnet,代码行数:101,代码来源:DataListAdapter.cs

示例6: RenderContents

        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (Extender.AdapterEnabled)
            {
                DataList dataList = Control as DataList;
                if (dataList != null)
                {
                    writer.Indent++;
                    writer.WriteLine();
                    writer.WriteBeginTag("table");
                    writer.WriteAttribute("cellpadding", "0");
                    writer.WriteAttribute("cellspacing", "0");
                    writer.WriteAttribute("summary", Control.ToolTip);
                    writer.Write(HtmlTextWriter.TagRightChar);
                    writer.Indent++;

                    if (dataList.HeaderTemplate != null)
                    {
                        PlaceHolder container = new PlaceHolder();
                        dataList.HeaderTemplate.InstantiateIn(container);
                        container.DataBind();

                        if ((container.Controls.Count == 1) && typeof(LiteralControl).IsInstanceOfType(container.Controls[0]))
                        {
                            writer.WriteLine();
                            writer.WriteBeginTag("caption");
                            writer.Write(HtmlTextWriter.TagRightChar);

                            LiteralControl literalControl = container.Controls[0] as LiteralControl;
                            writer.Write(literalControl.Text.Trim());

                            writer.WriteEndTag("caption");
                        }
                        else
                        {
                            writer.WriteLine();
                            writer.WriteBeginTag("thead");
                            writer.Write(HtmlTextWriter.TagRightChar);
                            writer.Indent++;

                            writer.WriteLine();
                            writer.WriteBeginTag("tr");
                            writer.Write(HtmlTextWriter.TagRightChar);
                            writer.Indent++;

                            writer.WriteLine();
                            writer.WriteBeginTag("th");
                            writer.WriteAttribute("colspan", RepeatColumns.ToString());
                            writer.Write(HtmlTextWriter.TagRightChar);
                            writer.Indent++;

                            writer.WriteLine();
                            container.RenderControl(writer);

                            writer.Indent--;
                            writer.WriteLine();
                            writer.WriteEndTag("th");

                            writer.Indent--;
                            writer.WriteLine();
                            writer.WriteEndTag("tr");

                            writer.Indent--;
                            writer.WriteLine();
                            writer.WriteEndTag("thead");
                        }
                    }

                    if (dataList.FooterTemplate != null)
                    {
                        writer.WriteLine();
                        writer.WriteBeginTag("tfoot");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        writer.WriteLine();
                        writer.WriteBeginTag("tr");
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        writer.WriteLine();
                        writer.WriteBeginTag("td");
                        writer.WriteAttribute("colspan", RepeatColumns.ToString());
                        writer.Write(HtmlTextWriter.TagRightChar);
                        writer.Indent++;

                        PlaceHolder container = new PlaceHolder();
                        dataList.FooterTemplate.InstantiateIn(container);
                        container.DataBind();
                        container.RenderControl(writer);

                        writer.Indent--;
                        writer.WriteLine();
                        writer.WriteEndTag("td");

                        writer.Indent--;
                        writer.WriteLine();
                        writer.WriteEndTag("tr");

                        writer.Indent--;
//.........这里部分代码省略.........
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:101,代码来源:DataListAdapter.cs

示例7: Render

 protected override void Render(HtmlTextWriter output)
 {
     using (PlaceHolder plh = new PlaceHolder())
     {
         if (DesignMode || Page.Header == null)
             RegisterCSSInclude(plh);
         Table table = new Table();
         table.CellPadding = 0;
         table.CellSpacing = 0;
         table.Rows.Add(new TableRow());
         table.Rows[0].Cells.Add(new TableCell());
         table.Rows[0].Cells.Add(new TableCell());
         table.Rows[0].Cells.Add(new TableCell());
         table.Rows[0].Cells[1].Style.Add(HtmlTextWriterStyle.PaddingRight, "5px");
         HtmlGenericControl txt = new HtmlGenericControl("input");
         txt.EnableViewState = false;
         txt.Attributes.Add("maxlength", "15");
         txt.Attributes.Add("size", "15");
         txt.Attributes.Add("value", Color);
         txt.Attributes.Add("id", ClientID);
         txt.Attributes.Add("name", UniqueID);
         //设置默认黑色
         txt.Attributes.CssStyle.Value = String.Format("height:17px;padding:2px;background-color:{0};", Color);
         table.Rows[0].Cells[0].Controls.Add(txt);
         //HtmlGenericControl colorBar = new HtmlGenericControl("div");
         //colorBar.EnableViewState = false;
         //colorBar.Attributes.CssStyle.Add(HtmlTextWriterStyle.Height, "21px");
         //colorBar.Attributes.CssStyle.Add(HtmlTextWriterStyle.Width, "5px");
         //colorBar.Attributes.CssStyle.Add("border", "solid 1px #7f9db9");
         //colorBar.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, Color);
         //table.Rows[0].Cells[1].Controls.Add(colorBar);
         HtmlInputImage btn = new HtmlInputImage();
         btn.Src = Page.ClientScript.GetWebResourceUrl(typeof(ColorPicker), "HeraDMS.ServerControls.ColorPicker.Images.ColorPickerIcon.jpg");
         btn.Attributes.Add("onclick", string.Format("colorPicker_{0}.ShowColorPicker(this,document.getElementById('{1}'));return false;", ClientID, ClientID));
         btn.Attributes.CssStyle.Add(HtmlTextWriterStyle.ZIndex, "1");
         HtmlGenericControl container = new HtmlGenericControl("div");
         container.EnableViewState = false;
         container.Controls.Add(btn);
         container.Attributes.CssStyle.Add(HtmlTextWriterStyle.Position, "static");
         container.Attributes.CssStyle.Add(HtmlTextWriterStyle.Display, "block");
         table.Rows[0].Cells[1].Controls.Add(container);
         plh.Controls.Add(table);
         plh.RenderControl(output);
     }
 }
开发者ID:chutinhha,项目名称:heradms,代码行数:45,代码来源:ColorPicker.cs

示例8: Render

        /// <summary>
        /// Renders this template to the specified <see cref="HtmlTextWriter" />
        /// </summary>
        /// <param name="writer">The <see cref="HtmlTextWriter" /> to which to render.</param>
        public void Render(HtmlTextWriter writer)
        {
            if (_string != null)
                writer.Write(_string);
            else if (_action != null)
                _action();
            else if (_actionWriter != null)
                _actionWriter(writer);
            else if (_template != null)
            {
                PlaceHolder ph = new PlaceHolder();

                _template.InstantiateIn(ph);

                // TODO?
                //using (HtmlTextWriter w = new HtmlTextWriter(writer))
                    ph.RenderControl(writer);
            }
        }
开发者ID:codingbat,项目名称:BandCamp,代码行数:23,代码来源:Template.cs


注:本文中的System.Web.UI.WebControls.PlaceHolder.RenderControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。