大家好,又见面了,我是你们的朋友全栈君。
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的例子:
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>
“
);
}
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>
“
);
}
}
}
}
void
RenderTabContent(HtmlTextWriter pOutPut)
{
for
(
int
i
=
0
; i
<
this
.Items.Count; i
++
)
{
if
(
this
.Items[i].Visible
==
true
)
{
this
.Items[i].RenderControl(pOutPut);
}
}
}
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>
“
);
}
转载于:https://www.cnblogs.com/kasafuma/archive/2011/04/06/2006666.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/162033.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...