DefaultEvent( "ClickNext" ):指定组件的默认事件
DefaultProperty( "NextText" ):指定组件的默认属性
Bindable(true or false):指定属性是否通常用于绑定
Category( "Appearance" ):指定其属性或事件将显示在可视化设计器中的类别
DefaultValue( typeof( Color ) , "" ):指定属性的默认值
Description( "The background color"):指定属性或事件的说明
TypeConverter(typeof( WebColorConverter )):指定用作此特性所绑定到的对象的转换器的类型
Browsable(true or false):指定一个属性或事件是否应显示在“属性”窗口中
DesignerSerializationVisibility( DesignerSerializationVisibility.Hidden ):指定在设计时序列化组件上的属性时所使用的持久性类型
==========================================================================
简单控件 事件
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace MyControls
{
/// <summary>
/// SummarydescriptionforMyEventManager.
/// </summary>
[DefaultEvent( " NextClick " ),DefaultProperty( " text " )]
public class MyEventManager:System.Web.UI.WebControls.WebControl,IPostBackEventHandler
{
public event EventHandlerNextClick;
public event EventHandlerPreClick;
[Bindable( true ),Category( " Behavior " ),DefaultValue( "" ),Description( " text " )]
public string text
{
get
{
return (( string )ViewState[ " text " ] == null ) ? string .Empty:( string )ViewState[ " text " ];
}
set
{
ViewState[ " text " ] = value;
}
}
protected virtual void OnNextClick(EventArgse)
{
if (NextClick != null )
{
NextClick( this ,EventArgs.Empty);
}
}
protected virtual void OnPreClick(EventArgse)
{
if (PreClick != null )
{
PreClick( this ,EventArgs.Empty);
}
}
void IPostBackEventHandler.RaisePostBackEvent( string EventArguments)
{
if (EventArguments == " Pre " )
{
OnPreClick(EventArgs.Empty);
Page.Trace.Warn( " PreButtonClick " );
}
else
{
OnNextClick(EventArgs.Empty);
Page.Trace.Warn( " NextButtonClick " );
}
}
[Bindable( true ),
Category( " Appearance " ),
DefaultValue( "" )]
protected override void Render(HtmlTextWriteroutput)
{
// output.Write(Text);
this .Attributes.AddAttributes(output);
output.AddAttribute(HtmlTextWriterAttribute.Onclick,Page.GetPostBackEventReference( this , " Pre " ));
output.AddAttribute( " language " , " javascript " );
output.RenderBeginTag(HtmlTextWriterTag.Button);
output.Write( " Pre " );
output.RenderEndTag();
output.AddAttribute(HtmlTextWriterAttribute.Onclick,Page.GetPostBackEventReference( this , " Next " ));
output.AddAttribute( " language " , " javascript " );
output.RenderBeginTag(HtmlTextWriterTag.Button);
output.Write( " Next " );
output.RenderEndTag();
base .Render(output);
}
}
}