0

DBにデータを保存するボタンのあるリピーターがあります。私の問題は、DBへの呼び出しに少し時間がかかり、ユーザーが[保存]を数回クリックして、複数のエントリがDBに追加される場合があることです。したがって、私の最初の考えは、スロバーを追加し、ボタンがクリックされたときにボタンを無効にすることでした。スロバーは回転しますが、ボタンが無効になっていると、サーバーへの呼び出しができなくなります。だから私はこれを見ましが、私はたくさんの異なるボタン(更新、追加、...)を持っているので、いくつかの異なるサーバー側のメソッドが呼び出されているので、投稿することはできません__doPostBack($(button).attr('id'),'')。だから私はajax呼び出しをする必要があるかもしれないと思っていましたが、他に何かアイデアがあるかどうかを確認したかったのです。これが私のコードです:これonClientClickは実際にはサーバー側でセットアップされていますが、これは基本的に行われていることです。

リピーター

<div style="position: relative; float: left;">
      <asp:Button ID="btnSave" runat="server" Text="Assign" OnClientClick="return fnAssignedButtonPressed(this);", OnClick="btnSave_Click" />
</div>

Javscript

function fnAssignedButtonPressed(button) {
//validating inputs
var valid = true;

        if(valid)
        {
           $(button).attr('disabled', 'disabled');
           showWaitCursor(true);
           __doPostBack($(button).attr('id'),'');
        }
  return valid;
}

サーバーサイド

protected void btnSave_Click(object sender, EventArgs e)
{
 //save
 // This method doesn't call called when I disable the button!!
}
4

2 に答える 2

0

シナリオによっては、Ajax が間違いなく適切なオプションになる可能性があります。それ以外の場合は、次のような jquery の UI ダイアログを使用して、お待ちくださいモーダルを表示できます。

$('<div class="dialog" title="Please Wait">Please wait while your request is processing</div>').dialog({
    modal: true,
    width: 350,
    open: function (event, ui) {
        $(".ui-dialog-titlebar-close").hide();
    },
});

サーバーが戻ると、モーダルは自動的に非表示になり、UI ダイアログのモーダル オプションが画面をグレー表示して、ユーザーが何もクリックできないようにします。

于 2012-05-18T18:09:41.083 に答える
0

私はこれをやり遂げましたが、私はそれについてどのように感じているかわかりません..

function fnAssignedButtonPressed(button) 
{ 
//validating inputs 
var valid = true;
     if(valid)
     {
       showWaitCursor(true);
       //set a timeout and then disable the button, this prevents the user from click the button multiple times.
       // need the timeout bc when the button becomes disabled it prevents the onlick event from firing.
       setTimeout(function() {fnDisableButton(button)}, 1); 
    }
}

function fnDisableButton(button)
{
    $(button).attr('disabled', 'disabled');
}
于 2012-05-18T18:09:12.863 に答える