会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
天行健,君子以自强不息;地势坤,君子以厚德载物
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
公告
asp.net中为TextBox Web服务器控件添加OnClick事件【转】
击文本框控件(TextBox)执行某个特殊的任务
在进行Web应用开发的时候,有时会需要使点击文本框控件(TextBox)执行某个特殊的任务,但TextBox却没有按钮那样的OnClick事件
Code
//
.aspx
<
asp:TextBox ID
=
"
TextBox1
"
runat
=
"
server
"
></
asp:TextBox
>
<
asp:Button ID
=
"
Button1
"
runat
=
"
server
"
OnClick
=
"
Button1_Click
"
Text
=
"
我被隐藏啦
"
style
=
"
display:none
"
/>
//
.aspx.cs
protected
void
Page_Load(
object
sender, EventArgs e)
{
//
1.x
//
TextBox1.Attributes["onclick"] = Page.GetPostBackEventReference(Button1);
//
2.0
TextBox1.Attributes[
"
onclick
"
]
=
ClientScript.GetPostBackEventReference(Button1,
null
);
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
Response.Write(DateTime.Now);
}
本文来自CSDN博客,转载请标明出处:http:
//
blog.csdn.net/z365days/archive/2008/01/05/2026534.aspx
posted on
2009-09-15 11:36
DongD
阅读(
458
) 评论(
0
)
收藏
举报
刷新页面
返回顶部