zoukankan
html css js c++ java
.net 1.1 LinkButton代码
.net 1.1 LinkButton代码
using
System;
using
System.ComponentModel;
using
System.Drawing.Design;
using
System.Web;
using
System.Web.UI;
using
System.Web.Util;
using
System.Security.Permissions;
using
System.Web.UI.WebControls;
namespace
JxtLibrary.Controls
{
public
class
LinkButton : WebControl, IPostBackEventHandler
{
private
static
readonly
object
EventClick
=
new
object
();
private
static
readonly
object
EventCommand
=
new
object
();
[Category(
"
Action
"
)]
public
event
EventHandler Click
{
add
{
base
.Events.AddHandler(EventClick, value);
}
remove
{
base
.Events.RemoveHandler(EventClick, value);
}
}
[Category(
"
Action
"
)]
public
event
CommandEventHandler Command
{
add
{
base
.Events.AddHandler(EventCommand, value);
}
remove
{
base
.Events.RemoveHandler(EventCommand, value);
}
}
public
LinkButton()
:
base
(HtmlTextWriterTag.A)
{
}
internal
static
string
GetClientValidatedPostback(Control control)
{
string
postBackEventReference
=
control.Page.GetPostBackEventReference(control);
return
(
"
{if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate())
"
+
postBackEventReference
+
"
}
"
);
}
protected
override
void
AddAttributesToRender(HtmlTextWriter writer)
{
if
(
this
.Page
!=
null
)
{
this
.Page.VerifyRenderingInServerForm(
this
);
}
base
.AddAttributesToRender(writer);
if
(
this
.Enabled
&&
(
this
.Page
!=
null
))
{
if
(
this
.CausesValidation
&&
(
this
.Page.Validators.Count
>
0
))
{
writer.AddAttribute(HtmlTextWriterAttribute.Href,
"
javascript:
"
+
GetClientValidatedPostback(
this
));
}
else
{
writer.AddAttribute(HtmlTextWriterAttribute.Href,
this
.Page.GetPostBackClientHyperlink(
this
,
""
));
}
}
}
protected
override
void
AddParsedSubObject(
object
obj)
{
if
(
this
.HasControls())
{
base
.AddParsedSubObject(obj);
}
else
if
(obj
is
LiteralControl)
{
this
.Text
=
((LiteralControl)obj).Text;
}
else
{
string
text
=
this
.Text;
if
(text.Length
!=
0
)
{
this
.Text
=
string
.Empty;
base
.AddParsedSubObject(
new
LiteralControl(text));
}
base
.AddParsedSubObject(obj);
}
}
protected
override
void
LoadViewState(
object
savedState)
{
if
(savedState
!=
null
)
{
base
.LoadViewState(savedState);
string
str
=
(
string
)
this
.ViewState[
"
Text
"
];
if
(str
!=
null
)
{
this
.Text
=
str;
}
}
}
protected
virtual
void
OnClick(EventArgs e)
{
EventHandler handler
=
(EventHandler)
base
.Events[EventClick];
if
(handler
!=
null
)
{
handler(
this
, e);
}
}
protected
virtual
void
OnCommand(CommandEventArgs e)
{
CommandEventHandler handler
=
(CommandEventHandler)
base
.Events[EventCommand];
if
(handler
!=
null
)
{
handler(
this
, e);
}
base
.RaiseBubbleEvent(
this
, e);
}
protected
override
void
OnPreRender(EventArgs e)
{
base
.OnPreRender(e);
if
((
this
.Page
!=
null
)
&&
this
.Enabled)
{
//
this.Page.RegisterPostBackScript();
}
}
protected
override
void
RenderContents(HtmlTextWriter writer)
{
if
(
this
.HasControls())
{
base
.RenderContents(writer);
}
else
{
writer.Write(
this
.Text);
}
}
void
IPostBackEventHandler.RaisePostBackEvent(
string
eventArgument)
{
if
(
this
.CausesValidation)
{
this
.Page.Validate();
}
this
.OnClick(
new
EventArgs());
this
.OnCommand(
new
CommandEventArgs(
this
.CommandName,
this
.CommandArgument));
}
[Category(
"
Behavior
"
), Bindable(
false
), DefaultValue(
true
)]
public
bool
CausesValidation
{
get
{
object
b
=
ViewState[
"
CausesValidation
"
];
return
((b
==
null
)
?
true
: (
bool
)b);
}
set
{
ViewState[
"
CausesValidation
"
]
=
value;
}
}
[Bindable(
true
), Category(
"
Behavior
"
), DefaultValue(
""
)]
public
string
CommandArgument
{
get
{
string
s
=
(
string
)ViewState[
"
CommandArgument
"
];
return
((s
==
null
)
?
String.Empty : s);
}
set
{
ViewState[
"
CommandArgument
"
]
=
value;
}
}
[Category(
"
Behavior
"
), DefaultValue(
""
)]
public
string
CommandName
{
get
{
string
s
=
(
string
)ViewState[
"
CommandName
"
];
return
((s
==
null
)
?
String.Empty : s);
}
set
{
ViewState[
"
CommandName
"
]
=
value;
}
}
[PersistenceMode(PersistenceMode.InnerDefaultProperty), Bindable(
true
), Category(
"
Appearance
"
), DefaultValue(
""
)]
public
virtual
string
Text
{
get
{
object
o
=
ViewState[
"
Text
"
];
return
((o
==
null
)
?
String.Empty : (
string
)o);
}
set
{
if
(HasControls())
{
Controls.Clear();
}
ViewState[
"
Text
"
]
=
value;
}
}
}
}
查看全文
相关阅读:
Linux运维常用的几个命令介绍【转】
Linux 删除文件后空间不释放【原创】
使用 Xtrabackup 在线对MySQL做主从复制【转】
用Centos7搭建小微企业Samba文件共享服务器【转】
工作流数据表设计
mysql函数大全
git 分支管理
Bootstap datetimepicker报错TypeError: intermediate value
分分钟搞定IOS远程消息推送
Windows10下安装OpenSSL
原文地址:https://www.cnblogs.com/jintan/p/1310136.html
最新文章
瓜子二手车的谎言!
TP5报错variable type error: array
页面回到顶部的三种实现(锚标记,js)
Excel还是那些事
2018电脑硬件榜单
2018入门微单相机推荐
PHPstorm最常用的快捷键,提高开发效率
Laravel.log日志超级大!怎么办!
PHPstorm自定义快捷键
在shell中如何判断字符串是否为有效的IP地址【转】
热门文章
Linux下多路径multipath配置【转】
screen命令使用方法【转】
Linux是对用户的密码的复杂度要求设置【转】
linux用户修改用户shell
Linux用户密码期限修改
tomcat+java的web程序持续占cpu高问题调试【转】
pip安装使用详解【转】
Serv-U设置允许用户更改密码【转】
RAID总结
架构师必须搞懂DNS【转】
Copyright © 2011-2022 走看看