Jquery Dialog意外关闭使用ASP Master Page

时间:2016-11-01 17:54:39

标签: javascript jquery asp.net jquery-ui dialog

当我按下"指定服务"按钮对话框出现,但似乎正在进行回发,对话框意外关闭

<asp:Content ID="Content0" ContentPlaceHolderID="ContentPLaceHolderHeader" runat="server">
          <script type="text/javascript">
          $( function() {
            var dialog;   


        dialog = $( "#dialog-form" ).dialog({
          autoOpen: false,
          height: 400,
          width: 350,
          modal: false,
          buttons: {        

          }
        });    


        $( "#spc" ).button().on( "click", function() {
          dialog.dialog( "open" );

        });
          } );
          </script>      

     </asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <button id="spc">Specify Services</button>
    <div id="dialog-form" title="Create new user">
            <p class="validateTips">All form fields are required.</p>

              <form>
                <fieldset>
                  <label for="name">Name</label>
                  <input type="text" name="name" id="name" >
                  <label for="email">Email</label>
                  <input type="text" name="email" id="email" >         

                  <input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
                </fieldset>
              </form>
            </div>

</asp:Content>

我尝试过不使用母版页/内容,但效果很好。

1 个答案:

答案 0 :(得分:0)

默认情况下,按钮标记用作提交按钮。因此,如果您不希望它进行回发,则需要指定按钮类型。

<button id="spc" type="button">Specify Services</button>

Button types