日期:2014-05-18 浏览次数:20562 次
$(document).ready(function(){
$("#UserLogin").click(function(){
var logintype=$("#LoginType").val();
var username=$("#UserName").val();
var userpwd=$("#UserPwd").val();
if(username=='')
{
alert('请输入用户名!');
return false;
}
if(userpwd=='')
{
alert('请输入密码!');
return false;
}
$.ajax({
type:"POST",
contentType: "application/json",
url:"/user/login.ashx",
data:"{LoginType:"+logintype+",UserName:"+username+",UserPwd:"+userpwd+"}",
dataType: 'json',
success: function(result) { //回调函数,result,返回值
$("#Login").html(result);
},
error:function(){
alert('错误');
}
});
});
});
IUserLogin userlogin = new IUserLogin();
public void ProcessRequest(HttpContext context)
{
string LoginType = Convert.ToString(context.Request.QueryString["LoginType"]);
string UserName = Convert.ToString(context.Request.QueryString["UserName"]);
string UserPwd = Convert.ToString(context.Request.QueryString["UserPwd"]);
UserInfo info = new UserInfo();
if (LoginType == string.Empty || LoginType == null || LoginType == "")
context.Response.Write("参数错误!");
if (LoginType == "id")
info.Userid = Convert.ToInt32(UserName);
if (LoginType == "user")
info.UserName = UserName;
if (LoginType == "email")
info.Email = UserName;
info.UserPwd = UserPwd;
context.Response.Write(userlogin.UserLogin(LoginType, info));
}