本文整理汇总了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");
//.........这里部分代码省略.........
示例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");
}
}
示例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--;
}
示例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");
}
}
示例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);
//.........这里部分代码省略.........
示例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--;
//.........这里部分代码省略.........
示例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);
}
}
示例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);
}
}