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;
}
}
}
}
查看全文
相关阅读:
CDH 重装 kafka 报错,挺常见的错误
SpringBoot + easyexcel + vue 下载 excel 问题
第二节 全球金融市场
第一节 金融市场概述
第1章-起 步
第3关-input()函数
第2关-条件判断与条件嵌套
风变编程-Python基础语法
第0关-千寻的名字
Git知识点记录3-Git基础
原文地址:https://www.cnblogs.com/jintan/p/1310136.html
最新文章
__fastfail(FAST_FAIL_STACK_COOKIE_CHECK_FAILURE)出错,堆栈 Cookie 检测代码检测到基于堆栈的缓冲区溢出问题;
上传第一个个人github项目总结(基于QT TLE下载工具)
Acconda设置境内源(清华、中科大源)以及恢复默认源方法
更新最新版acconda导致的原快捷方式图标丢失问题
配置win10 + python3.7 + cuda10.1.243 + cudnn 7.6.5 + TensorFlow(CPU+GPU) 2.1.0 + keras2.3.1安装出现的错误解决方案
将日期时间六个独立数据转换为QDatetime类型函数
第一篇(2018/11-2019/1/21)
C++Primer第五版 习题答案及知识点
C++Primer第五版 第十章 泛型算法
C++Primer第五版 第九章 顺序容器
热门文章
C++Primer第五版 第八章 IO库
QT QPainter 基础绘图
配置 Swagger 带 token 访问的两种方式
git 如何忽略已经提交的文件或文件夹 (.gitignore文件无效)
慕课网《Mybatis缓存详解》视频学习笔记
Linux中递归更改文件扩展名的命令
慕课网《二进制与Java中的基本数据类型》视频学习笔记
Java – 如何在 String.Format 中显示 % ?
SpringBoot 控制台输出 Swagger 接口文档地址
华为云大数据集群 kafka 组件报错解决 KrbException: Message stream modified (41)
Copyright © 2011-2022 走看看