日期:2014-05-16 浏览次数:20448 次
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm5.aspx.cs" Inherits="WebApplication5.WebForm5" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function Button2_onclick() {
document.getElementById("Button2").disabled = true;
document.getElementById("Button1").click();
document.getElementById("Button2").value = "正在提交中。。";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
服务端Button1隐藏掉,即:
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" style="display:none"/>
Button2调用js:
<input id="Button2" type="button" value="提交" onclick="return Button2_onclick()" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
{
public partial class WebForm5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "document.getElementById('Button2').disabled = false;", true);
}
}
}