Ajax邮箱、用户名唯一性验证实例代码

这篇文章主要介绍了Ajax邮箱、用户名唯一性验证实例代码,需要的朋友可以参考下

废话不多说了,直接给大家贴代码了,具体代码如下所示:

 

reg.ashx代码:

 using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebT1.Ti.html2 { ///  /// reg 的摘要说明 ///  public class reg : IHttpHandler { public void ProcessRequest(HttpContext context) { if (context.Request["email"] != null) { string strEmail = context.Request["email"]; List lstUser = DataService.GetUserList(); var v = lstUser.Where(p => p.Email == strEmail); int iCount = 0; if (v.Count() > 0) { iCount = 1; } context.Response.ContentType = "text/plain"; context.Response.Write(iCount.ToString()); } } public bool IsReusable { get { return false; } } } public class DataService { ///  /// 模拟已注册用户数据 ///  public static List GetUserList() { var list = new List(); list.Add(new UserModel() { Email = "t1@demo.com" }); list.Add(new UserModel() { Email = "t2@demo.com" }); list.Add(new UserModel() { Email = "t3@demo.com" }); list.Add(new UserModel() { Email = "t4@demo.com" }); list.Add(new UserModel() { Email = "t5@demo.com" }); return list; } } public class UserModel { public string Email { get; set; } } }

总结

以上就是Ajax邮箱、用户名唯一性验证实例代码的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » jQuery 答疑