當回發已經在進行時,禁止從asp.net回發一個帖子,即按鈕,鏈接,gridview頁面索引改變和排序等。目標瀏覽器是IE 6+。我寫了這兩個JavaScript我不知道如何將它應用於GridView頁面索引更改。當一個已經在進行中時禁止POST POST返回
<script type="text/javascript">
//isFormSubmitted variable is used to prevent the form submission while the server execution is in progress
var isFormSubmitted = false;
//If the form is already submitted, this function will return false preventing the form submission again.
function SubmitForm(msg)
{
try {
if(isFormSubmitted == true)
{
alert('A post back is already in progress. Please wait');
return false;
}
else
{
var res = false;
if (msg)
{
res = confirm(msg);
}
if (res == true)
{
isFormSubmitted = true;
}
return res;
}
} catch(ex) {}
}
function VerifySubmit()
{
if(isFormSubmitted == true)
{
alert('A post back is already in progress. Please wait');
return false;
}
else
{
isFormSubmitted = true;
return true;
}
}
</script>
對於按鈕,我可以將SubmitForm附加到OnClientClick這樣。
<asp:Button ID="btnCancel" runat="server" CssClass="button" Text="Cancel" OnClick="btnCancel_Click" OnClientClick="return SubmitForm('Do you want to continue with cancelling recent action?');" />
但我不知道如何將VerifySubmit附加到非提示控件,如gridview pager。
所有我要說的是????? – JonH 2010-07-21 19:51:26
是不是這樣,你想減少一個按鈕被按下後的二級帖子的可能性?類似這樣的: http://ddkonline.blogspot.com/2008/02/aspnet-double-postback-bug-strikes.html – Irwin 2010-07-21 19:54:22
不禁用回發我需要禁止其他回發帖子時回發仍在進行中。我有一個網頁,它執行從Excel文件到CRM系統的大約10萬條記錄的批量導入。我在網格上顯示記錄,然後當用戶按下進程時,我將處理服務器上的記錄,最後在同一個網格上顯示結果。但在處理過程中,我不希望用戶點擊say鏈接(即GridView PageIndex或任何其他按鈕)。所以基本上我希望用戶在一個回發完成之前等待。 – 2010-07-21 20:05:06