runxinzhi.com
首页
百度搜索
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
}
}
,
这个送给你!
相关阅读:
jsp servlet table 集合list 数据 绑定
Linux下“/”和“~”的区别
android 百度地图 定位获取位置失败 62错误
PostgreSQL 空间数据类型point、 line等
PostgreSQL 与 PostGIS
MySQL及navicat for mysql中文乱码
eclipse报错:Multiple annotations found at this line:
Multiple markers at this line
css中绝对定位和相对定位的区别
关于display的属性:block和inline-block以及inline的区别,float相关说明
原文地址:https://www.cnblogs.com/di305449473/p/1245800.html
最新文章
windows异常演示,指定异常类型,然后生成异常
RegisterUserFunc为测试对象添加新方法或重写已有方法
suse 源的添加与删除,以及源地址
Ubuntu下设置VNCServer
Ubuntu 开启telnet、ftp服务
debian7 安装VMware Tools
Debian7 apt源设置
两个shell脚本
JMeter 聚合报告之 90% Line 参数说明
adb常用命令
热门文章
Centos下安装Mongodb
Centos下安装Redis
python随便笔记。。。
登录失败三次锁定用户
从文件中读取内容生成字典
postman-根据接口文档进行测试
Python isdigit()方法
java通过jdbc插入中文到mysql显示乱码(问号或者乱码)
mysql命令运行sql文件
jsp读取后台数据乱码
Copyright © 2020-2023
润新知