Ajax.net实现loading登陆的效果
AjaxPro.dll
一,在aspx的页面的代码如下
一,在aspx的页面的代码如下
1<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="ajaxproloading.Default5" %>
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6<head runat="server">
7 <title>loaing</title>
8 <script language=javascript>
9 function Get_Name()
10 {
11 var name=document.getElementById("Text1").value;
12 var pwd=document.getElementById("Text2").value;
13 ajaxproloading.Default5.GetLogin(name,pwd,CallBackServer);
14 document.getElementById("loading").style.display="block";
15
16 }
17 function CallBackServer(res)
18 {
19 var success=res.value;
20 document.getElementById("loading").style.display="none";
21
22 if(success)
23 {
24 document.getElementById("ss").innerHTML="登陆成功";
25
26 }
27 else
28 {
29 document.getElementById("ss").innerHTML="登陆失败";
30 }
31 }
32 </script>
33</head>
34<body>
35 <form id="form1" runat="server">
36 <div>
37 <input id="Button1" type="button" value="button" onclick="Get_Name();" />
38 <input id="Text1" type="text" />
39 <input id="Text2" type="text" /></div>
40 <div id="loading" style="display:none;"><img src=9.gif />正在登陆</div>
41 <div id="ss"></div>
42 </form>
43</body>
44</html>
45
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5<html xmlns="http://www.w3.org/1999/xhtml" >
6<head runat="server">
7 <title>loaing</title>
8 <script language=javascript>
9 function Get_Name()
10 {
11 var name=document.getElementById("Text1").value;
12 var pwd=document.getElementById("Text2").value;
13 ajaxproloading.Default5.GetLogin(name,pwd,CallBackServer);
14 document.getElementById("loading").style.display="block";
15
16 }
17 function CallBackServer(res)
18 {
19 var success=res.value;
20 document.getElementById("loading").style.display="none";
21
22 if(success)
23 {
24 document.getElementById("ss").innerHTML="登陆成功";
25
26 }
27 else
28 {
29 document.getElementById("ss").innerHTML="登陆失败";
30 }
31 }
32 </script>
33</head>
34<body>
35 <form id="form1" runat="server">
36 <div>
37 <input id="Button1" type="button" value="button" onclick="Get_Name();" />
38 <input id="Text1" type="text" />
39 <input id="Text2" type="text" /></div>
40 <div id="loading" style="display:none;"><img src=9.gif />正在登陆</div>
41 <div id="ss"></div>
42 </form>
43</body>
44</html>
45
二,.cs的代码
1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Data.SqlClient;
12namespace ajaxproloading
13{
14 public partial class Default5 : System.Web.UI.Page
15 {
16 protected void Page_Load(object sender, EventArgs e)
17 {
18 AjaxPro.Utility.RegisterTypeForAjax(typeof(Default5));
19 }
20 [AjaxPro.AjaxMethod]
21 public bool GetLogin(string username,string userpwd)
22 {
23 System.Threading.Thread.Sleep(3000);
24 SqlConnection con = new SqlConnection("server=.;database=testajax;uid=sa;pwd=lanjie");
25 con.Open();
26 SqlCommand com = new SqlCommand();
27 com.CommandText = "select * from userinfo where username='" + username + "' and userpwd='" + userpwd+"'";
28 com.Connection = con;
29 SqlDataReader da = com.ExecuteReader();
30 if (da.Read())
31 {
32 con.Close();
33 return true;
34 }
35 else
36 {
37 con.Close();
38 return false;
39 }
40 }
41 }
42}
43
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using System.Data.SqlClient;
12namespace ajaxproloading
13{
14 public partial class Default5 : System.Web.UI.Page
15 {
16 protected void Page_Load(object sender, EventArgs e)
17 {
18 AjaxPro.Utility.RegisterTypeForAjax(typeof(Default5));
19 }
20 [AjaxPro.AjaxMethod]
21 public bool GetLogin(string username,string userpwd)
22 {
23 System.Threading.Thread.Sleep(3000);
24 SqlConnection con = new SqlConnection("server=.;database=testajax;uid=sa;pwd=lanjie");
25 con.Open();
26 SqlCommand com = new SqlCommand();
27 com.CommandText = "select * from userinfo where username='" + username + "' and userpwd='" + userpwd+"'";
28 com.Connection = con;
29 SqlDataReader da = com.ExecuteReader();
30 if (da.Read())
31 {
32 con.Close();
33 return true;
34 }
35 else
36 {
37 con.Close();
38 return false;
39 }
40 }
41 }
42}
43
平时中 收集的 其他高手的东西来补充自己咯。!!!
【源自】http://www.cnblogs.com/symjie520/archive/2007/04/17/716571.html
这个家伙很懒