0

jQueryでダイアログボックスを作成しました。ただし、ボタンをクリックすると、ダイアログボックスが数秒で消えます。ボタンにクリック イベントが登録されています。何らかの理由でボタンがポストバックされているため、ページをリロードしていると思いますが、なぜこれが起こっているのか、実際に何が起こっているのかわかりません。

誰かが私にこの問題を説明してもらえますか? Jクエリ:

$(function () {
         $("#dialog").dialog({
             autoOpen: false,
             show: {
                 effect: "bounce",
                 duration: 1000000000
             },

         });

         $("#opener").click(function () {
             $("#dialog").dialog("open");
         });
     });

ダイアログ コード:

<div id="dialog" title="Select the records which you want to combine">
    <asp:Label ID="Label1" runat="server" Text="Comments"></asp:Label>
    <asp:TextBox ID="TextBox2" runat="server" Height="59px" 
        style="margin-left: 13px" TextMode="MultiLine" Width="303px"></asp:TextBox>
    <asp:Button ID="Button2" runat="server" Text="Combine" />

</div>
<asp:Button ID="opener" runat="server" Text="Combine" 
    onclick="Button2_Click" />
4

1 に答える 1

2

デフォルトでは、ボタンは送信ボタンです。ボタンに type="button" を追加します。

また、ボタンは runat="server" として定義されており、サーバーの onclick イベントがあるため、もちろんサーバーへのポストバックを実行する必要があります。

通常のhtmlボタンを使用するだけです

<button id="opener" type="button>Combine</button>
于 2013-06-20T19:32:22.570 に答える