复制代码 代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient; //引入命名空间
using System.Data;
namespace 加载层
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ReadData : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
//获取外部传进来的变量值i
int i = Int32.Parse(context.Request.QueryString["i"]);
//连接数据库
SqlConnection con = new SqlConnection("data source=.;user id=sa;pwd=5239898;database=librarydatabase;");
con.Open();
SqlDataAdapter ada = new SqlDataAdapter("select * from reader where 序号='" + i + "'", con);
SqlCommandBuilder com = new SqlCommandBuilder(ada);
DataSet ds = new DataSet();
ada.Fill(ds, "reader");
con.Close();
//读取表中栏位为“姓名”的字段值,并传出
context.Response.Write(ds.Tables["reader"].Rows[0]["姓名"].ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
复制代码 代码如下:
/*当DOM加载完毕之后就自动为两个链接添加Click事件*/
$("document").ready(function() {
$("a[href=javascript]").click(function() {
chkform();
return false;
})
$("a[href=test]").click(function() {
$("#load").css("display", "none");
$("#mark").css("display", "none");
return false;
})
});
var chkform = function() {
new Request({
/*调用一般处理程序进行后台抓取数据并返回txt变量*/
url: 'ReadData.ashx?i=' + $("#Text1").attr("value"),
/*抓取数据成功之后*/
onSuccess: function(txt) {
$("#load").append("<P>" + txt + "</P>");
$("#load").css("display", "block");
$("#mark").css("display", "block");
},
/*正在抓取*/
onRequest: function() {
$("#load").append("<P>正在加载</P>");
},
/*数据加载失败*/
onFailure: function() {
alert('信息加载失败!');
}
}).send();
}
复制代码 代码如下:
#mark{
width: 100%;
background-color:White;
position:absolute;
left: 0px;
top: 0px;
height: 700px;
filter:alpha(opacity=70);
-moz-opacity:70;
opacity:70;
z-index:2;
display:none;
}
#load
{
background-color:Gray;
border: 1px solid #999;
font-size: 12px;
position:relative;
margin:0 auto;
margin-top:100px;
width:200px;
height:150px;
z-index:99;
display:none;
}
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="加载层._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>加载层</title>
<link type="text/css" href="main.css" />
<script type="text/javascript" src="mootools.js"></script> //记得引入这个javascript库文件
<script type="text/javascript" src="jquery-1.3.1-vsdoc.js"></script> //VS支持智能提示的文件,可有可无
<script type="text/javascript" src="jquery-1.3.1.js"></script> //记得引入JQuery
<script type="text/javascript" src="loaddata.js"></script>
</head>
<body>
<div>
<a href="javascript">点击加载</a>
<input type="text" /></div>
<div>
load <a href="test">试试</a>
</div>
<div>
</div>
</body>
</html>
新闻热点
疑难解答
图片精选