.aspx
復制代碼 代碼如下:
<script language="javascript">
function abc()
{
var mybutton=document.getElementById("Submit1");
mybutton.disabled=true; //變灰
__doPostBack("Submit1",""); //執行服務器端Submit1的click事件
}
</script>
<form id="Form1" method="post" runat="server">
...
<INPUT id="Submit1" type="submit" value="開始上傳" name="Submit1" runat="server">
....
</form>
.cs
復制代碼 代碼如下:
private void Page_Load(object sender, System.EventArgs e)
{
...
this.GetPostBackEventReference(Submit1); //這句很關鍵,有這句才能讓客戶端執行服務器端事件。
Submit1.Attributes.Add("onclick","abc();");
....
}