自定义复合控件[2]-引发缓存事件

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

namespace  csMathControl
{
    
///   <summary>
    
///  引发缓存事件
    
///   </summary>
    [DefaultProperty( " Text " ), 
        ToolboxData(
" <{0}:RenderText runat=server></{0}:RenderText> " )]
    
public   class  RenderText : System.Web.UI.WebControls.WebControl
    {
        
        [Bindable(
true ), 
            Category(
" Appearance " ), 
            DefaultValue(
"" )] 
        
public   string  Text 
        {
            
get
            {
                
if (ViewState[ " text " ] != null )
                
return  ViewState[ " text " ].ToString();
                
else
                    
return   null ;
            }
            
set
            {
                ViewState[
" text " =  value;
                OnChange(EventArgs.Empty);
            }
        }
        
///   <summary>  
        
///  将此控件呈现给指定的输出参数。
        
///   </summary>
        
///   <param name="output">  要写出到的 HTML 编写器  </param>
         protected   override   void  Render(HtmlTextWriter output)
        {
            
// output.Write(Text);
            output.AddAttribute( " value " , this .Text );
            output.RenderBeginTag(
" INPUT " );
            output.RenderEndTag();
        }
        
// ---------------事件--------------------
         ///
         public   event  EventHandler Change;
        
protected   virtual   void  OnChange(EventArgs e)
        {
            
if (Change != null )
                Change(
this ,e);
        }
        
// ----------------------------------
    }
}

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