Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > ajax

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

来源:中文源码网    浏览:143 次    日期:2024-05-16 10:28:32
【下载文档:  Ajax邮箱、用户名唯一性验证实例代码.txt 】


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邮箱、用户名唯一性验证实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对中文源码网网站的支持!

相关内容