![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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
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