大佬教程收集整理的这篇文章主要介绍了如何混合jQuery Mobile和ASP.NET,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Default.aspx的
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UCP.Default" %> <!DOCTYPE html> <html> <head> <title>UA Cover Plus</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> </head> <body> <!-- Login --> <div data-role="page" id="login"> <div data-role="header" data-position="fixed"> <h1>Login</h1> <a href="#Family" data-icon="gear" class="ui-btn-right" data-iconpos="notext" data-theme="b" >Options</a> </div> <div data-role="content" data-theme="a"> <input type="text" id="txtUserName" placeholder="Username" /> <input type="password" name="passwordinput" id="txtpassword" placeholder="password" value="" /> <a href="javascript:Authenticate();" data-role="button" data-icon="check" data-iconpos="right">Log Me In!</a> </div><!-- /content --> </div><!-- /page --> </body>
Ajax JQuery函数:
function Authenticate() { $.ajax({ type: "POST",url: "Default.aspx/Authenticate",data: "{'name': '" + $('#txtUserName').val() + "','pass': '" + $('#txtpassword').val() + "'}",contentType: "application/json; charset=utf-8",dataType: "json",success: function (msg) { if (msg.d != '-1') { userId = msg.d; GetCustomisedConsole(); } else { alert("Authentication Failed"); } },error: function () { alert("Error :("); } }); };
[WebMethod] public static int authenticate(String name,String pass) { using (DbContext db = new DbContext()) { var user = db.Users.Where(x => x.UserName == name && x.password == pass).SingLeorDefault(); if (user != null) { return user.Id; } else { return -1; } } }
我的问题是,这是它的意图吗?我问这个是因为我在jQuery示例中看到了表单和提交的使用,我不知道如何在asp.net中实现.
请看一下这个例子
以上是大佬教程为你收集整理的如何混合jQuery Mobile和ASP.NET全部内容,希望文章能够帮你解决如何混合jQuery Mobile和ASP.NET所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。