zoukankan
html css js c++ java
Coustom web control 自定义控件
简单控件 事件
EventManager
using
System;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.ComponentModel;
namespace
MyControls
{
/**/
///
<summary>
///
Summary description for MyEventManager.
///
</summary>
[DefaultEvent(
"
NextClick
"
),DefaultProperty(
"
text
"
)]
public
class
MyEventManager : System.Web.UI.WebControls.WebControl,IPostBackEventHandler
{
public
event
EventHandler NextClick;
public
event
EventHandler PreClick;
[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(EventArgs e)
{
if
(NextClick
!=
null
)
{
NextClick(
this
,EventArgs.Empty);
}
}
protected
virtual
void
OnPreClick(EventArgs e)
{
if
(PreClick
!=
null
)
{
PreClick(
this
,EventArgs.Empty);
}
}
void
IPostBackEventHandler.RaisePostBackEvent(
string
EventArguments)
{
if
( EventArguments
==
"
Pre
"
)
{
OnPreClick(EventArgs.Empty);
Page.Trace.Warn(
"
Pre Button Click
"
);
}
else
{
OnNextClick(EventArgs.Empty);
Page.Trace.Warn(
"
Next Button Click
"
);
}
}
[Bindable(
true
),
Category(
"
Appearance
"
),
DefaultValue(
""
)]
protected
override
void
Render(HtmlTextWriter output)
{
//
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);
}
}
}
查看全文
相关阅读:
BeanUtils.copyProperties的用法
Eclipse中GitLab的配置和使用入门
认识与入门 Markdown
mybatis基础配置
动态规划-最长公共子串
查找
Entity Framework Code First ---EF Power Tool 和MySql一起使用遇到的问题
使用TortoiseSVN碰到的几个问题(2)-冲突解决, 图标重载
使用TortoiseSVN碰到的几个问题(1)-导入,提交,更新
Asp.net MVC4 Step By Step(5)-使用Web API
原文地址:https://www.cnblogs.com/yizhinantian/p/558878.html
最新文章
GR&R
ROM, RAM, Flash Memory
Embedded System.
(C#) 多线程修改布尔值, volatile
(C/C++) Interview in English
(C/C++) Interview in English
[Sciter系列] MFC下的Sciter–4.HTML与图片资源内置
[Sciter系列] MFC下的Sciter–3.Sciter脚本与底层交互
[Sciter系列] MFC下的Sciter–2.Sciter中的事件,tiscript,语法
笨笨-歌词伴侣V1.2(酷狗KRC转LRC,LRC歌词批量下载)
热门文章
CodePage代码,MultiByteToWideChar
WTL汉化版2013.10.15
[Sciter系列] MFC下的Sciter–1.创建工程框架
Sciter/HTMLayout内存占用评测
代码高亮测试
Windows Live Writer测试插件
FastCGI
Mongodb的基本语法
使用cmd打开磁盘目录和文件
Java Calendar类的使用总结
Copyright © 2011-2022 走看看