自定义复合控件[5]获取包含的文本

using  System;
using  System.Web.UI;
using  System.Web.UI.WebControls;
using  System.ComponentModel;

namespace  csMathControl
{
    
///   <summary>
    
///  Center 的摘要说明。
    
///   </summary>
    [DefaultProperty( " Text " ), 
        ToolboxData(
" <{0}:Center runat=server></{0}:Center> " )]
    [ParseChildren(
false )]
    
public   class  Center : System.Web.UI.WebControls.WebControl,INamingContainer
    {
        
private   string  text;
    
        [Bindable(
true ), 
            Category(
" Appearance " ), 
            DefaultValue(
"" )] 
        
public   string  Text 
        {
            
get
            {
                
return  text;
            }

            
set
            {
                text 
=  value;
            }
        }

        
///   <summary>  
        
///  将此控件呈现给指定的输出参数。
        
///   </summary>
        
///   <param name="output">  要写出到的 HTML 编写器  </param>
         protected   override   void  Render(HtmlTextWriter output)
        {
            
// output.Write(Text);
            output.AddAttribute( " align " , " center " );
            output.AddStyleAttribute(
" BackGround-color " , " red " );
            
// pannel开始
            output.RenderBeginTag( " div " );
            
foreach (Control ctrItem  in  Controls)
            {
                ctrItem.RenderControl(output);
            }
            output.RenderEndTag();
        }
        }
}

你可能感兴趣的:(自定义)