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;
}
}
}
}
查看全文
相关阅读:
不会吧不会吧,还有开发不会Java填充PDF模板数据的,赶紧看看吧
关于Redis分布式锁这一篇应该是讲的最好的了,先收藏起来再看!
iOS-----后台运行
iOS-----使用GCD实现多线程
iOS-----线程同步与线程通信
iOS-----多线程之NSThread
iOS-----MFMessageCompose 和 MFMailComposeViewController的使用方法
iOS-----使用AddressBookUI管理联系人
iOS-----使用addressBook管理联系人之修改联系人
iOS-----简易地CocoaAsyncSocket使用
原文地址:https://www.cnblogs.com/jintan/p/1310136.html
最新文章
bcc-tools工具之softirqs
bcc-tools工具之hardirqs
bcc-tools工具之funclatency
前端基础之CSS样式
前端基础之HTML
Web服务本质
MySQL视图操作
MySQL记录操作
MySQL多表查询
MySQL单表查询
热门文章
使用Python操作MySQL数据库
MySQL表的完整性约束
MySQL支持的数据类型
建议收藏!利用Spring解决循环依赖,深入源码给你讲明白!
2020年终总结!这套spring面试题一线名企都爱问,你都掌握了哪些?
赶紧收藏!Spring MVC 万字长文笔记,我愿奉你为王者笔记!
单身狗福利!利用java实现每天给对象发情话,脱单指日可待!
java初学者必看!Java中封装和继承的案例,对你学java很有帮助!
【JVM专题】JVM从概述到调优图文详解,含思维脑图深度剖析!
面试官:小伙子,你给我简单说一下RocketMQ 整合 Spring Boot吧
Copyright © 2011-2022 走看看