csharp webform Button控件OnClick,OnClientClick事件

复制代码
代码
 1 <html xmlns="http://www.w3.org/1999/xhtml" >
 2 <head runat="server">
 3     <title>csharp webform Button控件OnClick,OnClientClick事件</title>
 4     <script language="javascript" type="text/javascript">
 5 function confirmthis()
 6 {
 7 if(confirm("Do you want to do a server trip?"))
 8 {
 9 return true;
10 }
11 else
12 {
13 return false;
14 }
15 }
16 </script>
17 </head>
18 <body>
19     <form id="form1" runat="server">
20     <div>
21         <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
22      <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button"  OnClientClick="return confirm('審批後將不能再修改,您確認審批嗎?')"/>
23         <br />
24         <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
25         <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" OnClientClick="return confirmthis();"/></div>
26     </form>
27 </body>
28 </html>
29 
30  
31 
32     public partial class button : System.Web.UI.Page
33     {
34         protected void Page_Load(object sender, EventArgs e)
35         {
36 
37         }
38         protected void Button1_Click(object sender, EventArgs e)
39         {
40             this.TextBox1.Text = "click me";
41         }
42 
43         protected void Button2_Click(object sender, EventArgs e)
44         {
45             this.TextBox2.Text = "Do you want to do a server trip";
46         }
47     }
48 
复制代码

 

posted @   ®Geovin Du Dream Park™  阅读(3219)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
< 2010年8月 >
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 1 2 3 4
5 6 7 8 9 10 11
点击右上角即可分享
微信分享提示