Render,RenderChildren,RenderControl
protected internal virtual void Render(HtmlTextWriter writer)
{
this.RenderChildren(writer);
}
protected internal virtual void RenderChildren(HtmlTextWriter writer)
{
ICollection children = (this._occasionalFields == null) ? null : ((ICollection) this._occasionalFields.Controls);
this.RenderChildrenInternal(writer, children);
}
internal void RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
{
if ((this.RareFields != null) && (this.RareFields.RenderMethod != null))
{
writer.BeginRender();
this.RareFields.RenderMethod(writer, this);
writer.EndRender();
}
else if (children != null)
{
foreach (Control control in children)
{
control.RenderControl(writer);
}
}
}
public virtual void RenderControl(HtmlTextWriter writer)
{
this.RenderControl(writer, this.Adapter);
}
protected void RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
{
if (!this.flags[0x10] && !this.flags[0x200])
{
HttpContext context = (this.Page == null) ? null : this.Page._context;
if ((context != null) && context.TraceIsEnabled)
{
int bufferedLength = context.Response.GetBufferedLength();
this.RenderControlInternal(writer, adapter);
int num2 = context.Response.GetBufferedLength();
context.Trace.AddControlSize(this.UniqueID, num2 - bufferedLength);
}
else
{
this.RenderControlInternal(writer, adapter);
}
}
}
private void RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
{
if (adapter != null)
{
adapter.BeginRender(writer);
adapter.Render(writer);
adapter.EndRender(writer);
}
else
{
this.Render(writer);
}
}
Render----->RenderChilds---->RenderControl------Render
一个重写Render的例子:
{
this.RenderChildren(writer);
}
protected internal virtual void RenderChildren(HtmlTextWriter writer)
{
ICollection children = (this._occasionalFields == null) ? null : ((ICollection) this._occasionalFields.Controls);
this.RenderChildrenInternal(writer, children);
}
internal void RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
{
if ((this.RareFields != null) && (this.RareFields.RenderMethod != null))
{
writer.BeginRender();
this.RareFields.RenderMethod(writer, this);
writer.EndRender();
}
else if (children != null)
{
foreach (Control control in children)
{
control.RenderControl(writer);
}
}
}
public virtual void RenderControl(HtmlTextWriter writer)
{
this.RenderControl(writer, this.Adapter);
}
protected void RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
{
if (!this.flags[0x10] && !this.flags[0x200])
{
HttpContext context = (this.Page == null) ? null : this.Page._context;
if ((context != null) && context.TraceIsEnabled)
{
int bufferedLength = context.Response.GetBufferedLength();
this.RenderControlInternal(writer, adapter);
int num2 = context.Response.GetBufferedLength();
context.Trace.AddControlSize(this.UniqueID, num2 - bufferedLength);
}
else
{
this.RenderControlInternal(writer, adapter);
}
}
}
private void RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
{
if (adapter != null)
{
adapter.BeginRender(writer);
adapter.Render(writer);
adapter.EndRender(writer);
}
else
{
this.Render(writer);
}
}
Render----->RenderChilds---->RenderControl------Render
一个重写Render的例子:
protected override void Render(HtmlTextWriter pOutPut)
{
pOutPut.Write("<Div Class=\"TabControl tab-pane\" ID=\"" + this.UniqueID + "_Tab\" Style=\"" + EPWebControl.GetControlStyle(this.Width, base.Style) + "\">");
//隐藏的控件
this.SelectedTab.RenderControl(pOutPut);
//标签头部
pOutPut.Write("<DIV Class=\"tab-row\">");
this.RenderTabButton(pOutPut);
pOutPut.Write("</Div><Div>");
//标签内容
this.RenderTabContent(pOutPut);
pOutPut.Write("</Div></Div>");
}
{
pOutPut.Write("<Div Class=\"TabControl tab-pane\" ID=\"" + this.UniqueID + "_Tab\" Style=\"" + EPWebControl.GetControlStyle(this.Width, base.Style) + "\">");
//隐藏的控件
this.SelectedTab.RenderControl(pOutPut);
//标签头部
pOutPut.Write("<DIV Class=\"tab-row\">");
this.RenderTabButton(pOutPut);
pOutPut.Write("</Div><Div>");
//标签内容
this.RenderTabContent(pOutPut);
pOutPut.Write("</Div></Div>");
}
private void RenderTabButton(HtmlTextWriter pOutPut)
{
for (int num1 = 0; num1 < this.Items.Count; num1++)
{
if(this.Items[num1].Visible == true)
{
if (this.Items[num1].Selected)
{
pOutPut.Write("<H2 class=\"tab hover selected\" onMouseOver=\"Tab_OnMouseOver(this)\" onMouseOut=\"Tab_OnMouseOut(this)\">" + this.Items[num1].Caption + "</H2>");
}
else
{
pOutPut.Write("<H2 class=\"tab\" onMouseOver=\"Tab_OnMouseOver(this)\" onMouseOut=\"Tab_OnMouseOut(this)\" onClick=\"Tab_OnSelectServerClick(this,'" + this.Items[num1].UniqueID + "');" + this.Page.GetPostBackEventReference(this, "") + "\">" + this.Items[num1].Caption + "</H2>");
}
}
}
}
{
for (int num1 = 0; num1 < this.Items.Count; num1++)
{
if(this.Items[num1].Visible == true)
{
if (this.Items[num1].Selected)
{
pOutPut.Write("<H2 class=\"tab hover selected\" onMouseOver=\"Tab_OnMouseOver(this)\" onMouseOut=\"Tab_OnMouseOut(this)\">" + this.Items[num1].Caption + "</H2>");
}
else
{
pOutPut.Write("<H2 class=\"tab\" onMouseOver=\"Tab_OnMouseOver(this)\" onMouseOut=\"Tab_OnMouseOut(this)\" onClick=\"Tab_OnSelectServerClick(this,'" + this.Items[num1].UniqueID + "');" + this.Page.GetPostBackEventReference(this, "") + "\">" + this.Items[num1].Caption + "</H2>");
}
}
}
}
private void RenderTabContent(HtmlTextWriter pOutPut)
{
for (int i = 0; i < this.Items.Count; i++)
{
if(this.Items[i].Visible == true)
{
this.Items[i].RenderControl(pOutPut);
}
}
}
{
for (int i = 0; i < this.Items.Count; i++)
{
if(this.Items[i].Visible == true)
{
this.Items[i].RenderControl(pOutPut);
}
}
}
item的 Render
protected override void Render(HtmlTextWriter pOutPut)
{
if(this.Visible)
{
if (this.Selected)
{
pOutPut.Write(string.Concat(new object[] { "<DIV id=\"", this.UniqueID, "\" class=\"tab-page\" style=\"Height:", this._Owner.Height, ";Width:100%;DISPLAY: block\">" }));
}
else
{
pOutPut.Write(string.Concat(new object[] { "<DIV id=\"", this.UniqueID, "\" class=\"tab-page\" style=\"Height:", this._Owner.Height, ";Width:100%;DISPLAY: none\">" }));
}
}
this.RenderChildren(pOutPut);
pOutPut.Write("</DIV>");
}
{
if(this.Visible)
{
if (this.Selected)
{
pOutPut.Write(string.Concat(new object[] { "<DIV id=\"", this.UniqueID, "\" class=\"tab-page\" style=\"Height:", this._Owner.Height, ";Width:100%;DISPLAY: block\">" }));
}
else
{
pOutPut.Write(string.Concat(new object[] { "<DIV id=\"", this.UniqueID, "\" class=\"tab-page\" style=\"Height:", this._Owner.Height, ";Width:100%;DISPLAY: none\">" }));
}
}
this.RenderChildren(pOutPut);
pOutPut.Write("</DIV>");
}