DEFAULT.ASPX
DEFAULT.ASPX.CS
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
- <script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script>
- function runme() {
- $.ajax({
- type: "POST",
- url: "default.aspx/checkLogin",
- contentType: "application/json; charset=utf-8",
- data: "{'username':'" + $('#un').val() + "','password':'" + $('#pw').val() + "'}",
- dataType: "json",
- success: function (response) {
- var names = response.d;
- alert(names);
- },
- failure: function (response) {
- alert(response.d);
- }
- });
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <a href="#popupLogin" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-icon="check" data-theme="a" data-transition="pop">Sign in</a>
- <div data-role="popup" id="popupMenu" data-theme="a">
- <div data-role="popup" id="popupLogin" data-theme="a" class="ui-corner-all">
- <div style="padding: 10px 20px;">
- <h3>Please sign in</h3>
- <label for="un" class="ui-hidden-accessible">Username:</label>
- <input name="user" id="un" value="" placeholder="username" data-theme="a" type="text" />
- <label for="pw" class="ui-hidden-accessible">Password:</label>
- <input name="pass" id="pw" value="" placeholder="password" data-theme="a" type="password" />
- <button data-theme="b" data-icon="check" onclick="runme()">Sign in</button>
- </div>
- </div>
- </div>
- </form>
- </body>
- </html>
DEFAULT.ASPX.CS
- [WebMethod]
- public static string checkLogin(string username, string password)
- {
- Dictionary<string, string> name = new Dictionary<string, string>();
- name.Add(username, password);
- string myJsonString = (new JavaScriptSerializer()).Serialize(name);
- return myJsonString;
- }
No comments:
Post a Comment