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的例子:

 

 

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> " );
        }

 

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> " );
                        }
                    }
                }
            
        }

 



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);
                }
            }
        }
 
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> " );
        }
 

 

转载于:https://www.cnblogs.com/kasafuma/archive/2011/04/06/2006666.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值