zoukankan
html css js c++ java
asp.net控件开发基础(3)
类型可供选择的按钮自定义控件
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Web.UI;
using
System.ComponentModel;
namespace
ComponentControl
{
public
class
Ctrl5:Control,IPostBackEventHandler
{
private
static
readonly
object
obj
=
new
object
();
[Description(
"
按钮显示的类型
"
)]
public
BtnType ButtonType
{
get
{
return
ViewState[
"
ButtonType
"
]
==
null
?
BtnType.Button : (BtnType)ViewState[
"
ButtonType
"
]; }
set
{ ViewState[
"
ButtonType
"
]
=
value; }
}
//
事件
public
virtual
event
EventHandler Click
{
add
{
Events.AddHandler(obj, value);
}
remove
{
Events.RemoveHandler(obj, value);
}
}
//
控件重写
protected
override
void
Render(HtmlTextWriter writer)
{
if
(ButtonType
==
BtnType.Button)
writer.Write(
"
<input type=submit name=
"
+
this
.UniqueID
+
"
value=Button />
"
);
else
if
(ButtonType
==
BtnType.LinkButton)
writer.Write(
"
<a href=
"
+
Page.GetPostBackClientHyperlink(
this
,
""
)
+
"
>Button</a>
"
);
}
IPostBackEventHandler 成员
#region
IPostBackEventHandler 成员
public
void
RaisePostBackEvent(
string
eventArgument)
{
EventHandler child
=
(EventHandler)Events[obj];
if
(child
!=
null
)
child(
this
, EventArgs.Empty);
}
#endregion
}
//
按钮类型枚举
public
enum
BtnType
{
Button,
LinkButton
}
}
,
这个送给你!
查看全文
相关阅读:
使用Astah画UML类图经验总结
Qt的四个常见的图像叠加模式
获取Linux时间函数
DBus学习网站
线程属性pthread_attr_t简介
Secure CRT 自动记录日志log配置
MySQL的group_concat()函数合并多行数据
MySQL的Limit详解
异步查询json传日期格式到前台,变成了时间戳的格式
启动studio报错Gradle error
原文地址:https://www.cnblogs.com/di305449473/p/1245800.html
最新文章
WinForm特效:同时让两个窗体有激活效果
图像处理之相似图片识别(直方图应用篇)
C#中使用SQLite数据库简介(下)
Python学习---Django路由系统【all】
Python学习---Django重点之静态资源配置
Python学习---Django的基础操作180116
Python学习---Django的基础学习
Python学习---Python的框架基础学习
JQuery学习---JQuery深入学习
JQuery学习---JQuery基础知识
热门文章
JavaScript学习---JavaScript深入学习
CSS学习---css基础知识0105
HTML学习---基础知识学习
Mysql学习---Python操作Mysql 1231
Mysql学习---索引的学习 180101
Mysql学习---使用Python执行存储过程
Mysql学习---视图/触发器/存储过程/函数/执行计划/sql优化 180101
Qt之美(一):D指针/私有实现
hue, saturation, and brightness:色调、饱和度和亮度
音响理论基础入门:Gain(增益)
Copyright © 2011-2022 走看看