Ajax+asp.net实现用户登陆_.docx

上传人:啊飒飒 文档编号:11644226 上传时间:2021-08-27 格式:DOCX 页数:10 大小:13.30KB
返回 下载 相关 举报
Ajax+asp.net实现用户登陆_.docx_第1页
第1页 / 共10页
Ajax+asp.net实现用户登陆_.docx_第2页
第2页 / 共10页
Ajax+asp.net实现用户登陆_.docx_第3页
第3页 / 共10页
Ajax+asp.net实现用户登陆_.docx_第4页
第4页 / 共10页
Ajax+asp.net实现用户登陆_.docx_第5页
第5页 / 共10页
亲,该文档总共10页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《Ajax+asp.net实现用户登陆_.docx》由会员分享,可在线阅读,更多相关《Ajax+asp.net实现用户登陆_.docx(10页珍藏版)》请在三一文库上搜索。

1、Ajax+实现用户登陆_ 这篇文章主要介绍了Ajax+实现用户登陆,主要是为了练习ajax的用法方法,有需要的小伙伴参考下。 以用户登录为例练习ajax的用法方法 login.html !DOCTYPE html html xmlns= head meta http-equiv=Content-Type content=text/html; charset=utf-8/ title/title script type=text/javascript var obj = createobj(); function login(name, pwd) var urlstr = = + name +

2、password= + pwd; obj.open(get, urlstr, true); obj.onreadystatechange = dowork; obj.send(); function dowork() if (obj.readyState = 4) if (obj.status = 200) document.getElementById(msg).innerText = obj.responseText; /创建对象 function createobj() var xmlHttp = null; try /非IE扫瞄器 xmlHttp = new XMLHttpReques

3、t(); catch (e) /IE扫瞄器 try xmlHttp = new ActiveXObject(Msxml2.HTTP); catch (e) xmlHttp = new ActiveXObject(Microsoft.XMLHTTP); return xmlHttp; /script /head body table tr td align=center colspan=2登录/td /tr tr td用户名:/td tdinput type=text id=username name=username /td /tr tr td密码:/td tdinput type=passw

4、ord id=password name=password /td /tr tr td input type=submit value=登录 onclick=login(document.getElementById(username).value,document.getElementById(password).value) / /td td input type=reset value=清空 / /td tdspan id=msg/span/td /tr /table /body /html DAL.cs using System; using System.Collections.Ge

5、neric; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; namespace AJAXtest public class DAL private string connstr = server=acer-pc;database=mydatabase;user id=sa;password=123456; public DataTable selectDB(string sql) DataTable dt = new DataTable(); try SqlConnect

6、ion conn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); sda.Fill(dt); catch(Exception e) return dt; BLL.cs using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web; namespace AJAXtest public class BLL public bool login(

7、string username,string password) try string sql = select password from Users where username= + username + ; DAL sqlSelect = new DAL(); DataTable dt = sqlSelect.selectDB(sql); if (dt.Rows0password.ToString() != password) return false; catch (Exception) return true; Server.aspx.cs using System; using

8、System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace AJAXtest public partial class Server : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) string username = Requestusername.ToString(); string passwor

9、d = Requestpassword.ToString(); BLL b = new BLL(); if (b.login(username, password) Response.Write(登录胜利); Response.End(); else Response.Write(登录失败); Response.End(); Server.aspx % Page Language=C# AutoEventWireup=true CodeBehind=Server.aspx.cs Inherits=AJAXtest.Server % !DOCTYPE html html xmlns= head runat=server meta http-equiv=Content-Type content=text/html; charset=utf-8/ title/title /head body form id=form1 runat=server div /div /form /body /html Ajax+实现用户登陆 三联 以上所述就是本文的全部内容了,盼望大家能够喜爱。 更多信息请查看IT技术专栏 .

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1