日期:2014-05-18 浏览次数:20478 次
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Button2.OnClientClick = "return confirm('是否确认执行?');"; Page.ClientScript.RegisterStartupScript(Page.GetType(), "x", "document.getElementById('" + Button2.ClientID + "').click()", true); } protected void Button2_Click(object sender, EventArgs e) { Response.Write("Button2_Click执行了"); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form runat="server"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button1" /> <asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" /> </form> </body> </html>