All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
Visual C++ 6.0教程:条件编译指令
十 Forms_[Html教程]
php中计算时间差的几种方法_[PHP教程]
Asp.net,MVC2.0初级教程-添加操作_[Asp.Net教程]
VS.net调试ASP.NET项目出错原因及解决_[Asp.Net教程]
动态网页制作PHP中Session的概念_php资料_编程技术
ASP.NET,2.0,绑定高级技巧_[Asp.Net教程]
用php实现广告轮播_php资料_编程技术
Asp.net,Socket,客户端(发送和接收数据,)_[Asp.Net教程]
C++封装与访问控制[二.二]
Reading number is top 10 pictures
NeedWallpaper2
China's programmers are live what kind, had a look at will know that
So beauty, will let you spray blood9
Beautiful vacuum girl3
邪恶搞笑内涵图
The real super beauty15
Send some Valentine's day cartoon
来几张有特色的图片
Average female college students3
这才是真正的人体艺术4
Download software ranking
Unix video tutorial6
Call Of Duty5
Be there or be square
C++教程第四版
dreamweaver8中文版
linux高级编程
White deer villiage
美女写真2
Boxer's Top ten classic battle10
金山office2007
delv published in(发表于) 2014/1/6 8:47:30 Edit(编辑)
Ajax简单客户登陆验证_[Asp.Net教程]

Ajax简单客户登陆验证_[Asp.Net教程]

Ajax简单客户登陆验证_[Asp.Net教程]























服务器端操作方便之处我就不吹了,地球人都知道,它最烦莫过于页面刷新,头都被刷晕了,而且他在刷新的时候,还触发服务器端的事件(解决方案:http://skylaugh.cnblogs.com/archive/2006/06/05/418010.html),现在Ajax的出现,他们的结合是发展的必然!




一、介绍一下Ajax在Asp.Net中的基本使用
1、在工程中引入Ajax.dll文件。
  Ajax.dll实现XmlHttpRequest请求服务器的实现细节。.net项目中,添加上对其的引用,就可以进




行相应封装操作了。




2、在web.config中设置HttpHandle
  


3、在 与间加入一些引用如下:






二、介绍正题-用户登录验证
1、前台Html:














usename















pwd



























2、引用Js文件








login.Js文件
// 提取控件值
function getValueById(pObjID){
var obj=document.getElementById(pObjID);
try{
return obj.value;
}catch(e){
alert("控件:"+pObjID+" 不存在,或没有value属性");
}
}




function Login(obj)
{
this.OBJ = obj;
this.GetLogin=function()
{
var returnValue;
var username=getValueById('txtUsername');
var password=getValueById('txtPassword');
if(!username||!password)
{
alert('请输入用户名与密码!');
return;
}
try
{
returnValue=this.OBJ.Login(username,password).value;
}catch(e)
{
alert('登录出错,请稍后再试或与管理员联系');
}
switch(returnValue)
{

case 1:
alert('对不起,您输入的用户名或密码不正确或者不是管理员!');
break;
case 0:
alert('管理员登录成功!');
window.document.location.href('../Error.aspx');
break;
default:
alert('登录失败,请稍后再试或与管理员联系'+returnValue);
break;
}
}
}




3、.cs文件




private void Page_Load(object sender, System.EventArgs e)
{
Ajax.Utility.RegisterTypeForAjax(typeof(testAjax));
}




[Ajax.AjaxMethod()]
public int Login(string username,string password)
{
// 管理员登陆入口
Action.Common.CDB cdb = new Action.Common.CDB();
if("admin"==cdb.ExeScalar("select upower from users where




uname='"+username+"' and upwd='"+password+"'"))
return 0;
else
return 1;
}




来源:网络












































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.