组件开发中常用的属性

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 ):指定在设计时序列化组件上的属性时所使用的持久性类型

==========================================================================

简单控件 事件

EventManager
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->usingSystem;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.ComponentModel;


namespaceMyControls
{
/**////<summary>
///SummarydescriptionforMyEventManager.
///</summary>

[DefaultEvent("NextClick"),DefaultProperty("text")]
publicclassMyEventManager:System.Web.UI.WebControls.WebControl,IPostBackEventHandler
{

publiceventEventHandlerNextClick;
publiceventEventHandlerPreClick;

[Bindable(
true),Category("Behavior"),DefaultValue(""),Description("text")]
publicstringtext
{
get
{
return((string)ViewState["text"]==null)?string.Empty:(string)ViewState["text"];
}

set
{
ViewState[
"text"]=value;
}

}


protectedvirtualvoidOnNextClick(EventArgse)
{
if(NextClick!=null)
{
NextClick(
this,EventArgs.Empty);
}


}


protectedvirtualvoidOnPreClick(EventArgse)
{
if(PreClick!=null)
{
PreClick(
this,EventArgs.Empty);
}


}


voidIPostBackEventHandler.RaisePostBackEvent(stringEventArguments)
{
if(EventArguments=="Pre")
{
OnPreClick(EventArgs.Empty);
Page.Trace.Warn(
"PreButtonClick");
}

else
{
OnNextClick(EventArgs.Empty);
Page.Trace.Warn(
"NextButtonClick");
}

}


[Bindable(
true),
Category(
"Appearance"),
DefaultValue(
"")]


protectedoverridevoidRender(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);
}

}

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值