带jquery的asp.NETC

带jquery的asp.NETC,jquery,asp.net,Jquery,Asp.net,谁能告诉我我做错了什么 ContactForm.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContactForm.aspx.cs" Inherits="ContactForm" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-trans

谁能告诉我我做错了什么

ContactForm.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ContactForm.aspx.cs" Inherits="ContactForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>


    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.3/jquery-ui.js"></script>


    <link rel="stylesheet" href="Scripts/ContactForm.css"> <%--this line need to be here before line 2--%>
   <script src="Scripts/ContactForm.js"></script>  <%--line 2--%>
</head>
<body>

 <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" value="Jane Smith" class="text ui-widget-content ui-corner-all">

      <!-- Allow form submission with keyboard without duplicating the dialog button -->
      <input type="submit" tabindex="-1" style="position:absolute; top:-1000px">
    </fieldset>
  </form>
</div>


<div id="users-contain" class="ui-widget">
  <h1>Existing Users:</h1>
  <table id="users" class="ui-widget ui-widget-content">
    <thead>
      <tr class="ui-widget-header ">
        <th>Name</th>      
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>        
      </tr>
    </tbody>
  </table>
</div>
<%--<button id="btnContactForm">Create new user</button>--%>

  <form id="form1" runat="server">
    <div>
    <asp:Button ID="btnContactForm" runat="server" Text="Button" />
    </div>
  </form>

</body>
</html>
ContactForm.js

$(document).ready(function () {
    var dialog, form,      
      name = $("#name"),      
      allFields = $([]).add(name),
      tips = $(".validateTips");

    function updateTips(t) {
        tips
        .text(t)
        .addClass("ui-state-highlight");
        setTimeout(function () {
            tips.removeClass("ui-state-highlight", 1500);
        }, 500);
    }

    function checkLength(o, n, min, max) {
        if (o.val().length > max || o.val().length < min) {
            o.addClass("ui-state-error");
            updateTips("Length of " + n + " must be between " +
          min + " and " + max + ".");
            return false;
        } else {
            return true;
        }
    }

    function checkRegexp(o, regexp, n) {
        if (!(regexp.test(o.val()))) {
            o.addClass("ui-state-error");
            updateTips(n);
            return false;
        } else {
            return true;
        }
    }

    function addUser() {
        var valid = true;
        allFields.removeClass("ui-state-error");

        valid = valid && checkLength(name, "username", 3, 16);


        valid = valid && checkRegexp(name, /^[a-z]([0-9a-z_\s])+$/i, "Username may consist of a-z, 0-9, underscores, spaces and must begin with a letter.");


        if (valid) {
            $("#users tbody").append("<tr>" +
          "<td>" + name.val() + "</td>" +          
        "</tr>");
            dialog.dialog("close");
        }
        return valid;
    }

    dialog = $("#dialog-form").dialog({
        autoOpen: false,
        height: 300,
        width: 350,
        modal: true,
        buttons: {
            "Create an account": addUser,
            Cancel: function () {
                dialog.dialog("close");
            }
        },
        close: function () {
            form[0].reset();
            allFields.removeClass("ui-state-error");
        }
    });

    form = dialog.find("form").on("submit", function (event) {
        event.preventDefault();
        addUser();
    });

    $("#btnContactForm").button().on("click", function () {
        dialog.dialog("open");
    });
});
我的问题是: 1.工作:

<button id="btnContactForm">Create new user</button>
asp.net按钮不工作:

当我使用asp.net按钮2时,模式窗体会弹出并在一秒钟内消失

你的真实身份是什么?浏览页面时,右键单击页面以查看源代码。您可能还希望注释掉Cancel:function{dialog.dialogclose;}以进行调试
<button id="btnContactForm">Create new user</button>