|
|
2007年2月1日
招聘(net程序员) 1 一年以上.net开发经验 2 熟练掌握asp.net(C#)及MSSQL开发技术 3 对Web开发技术(HTML、JavaScript、CSS等)有一定的了解 4 有良好的敬业精神、学习能力、沟通能力和团队协作能力 5 有良好的编码规范、文档习惯 6 有电子商务平台开发者及熟悉AJAX者优先考虑。 工作地点上海 待遇包吃住 住宿条件 (有电话,冰箱等) 薪水范围(2k以上根据个人条件而定) 联系人:李先生 Tel :15920000648 直接找我就OK 有意者发Email:wowlzz@hotmail.com 面试地点深圳 8号一起去上海 通过者
称呼:Everest 或者Mrs Li QQ:156417825 MSN:wowlzz@hotmail.com Mail:wow_lzz@yahoo.com.cn 0755-28706680
随着B/S模式应用开发的发展,使用这种模式编写应用程序的程序员也越来越多。但是由于这个行业的入门门槛不高,程序员的水平及经验也参差不齐,相当大一部分程序员在编写代码的时候,没有对用户输入数据的合法性进行判断,使应用程序存在安全隐患。用户可以提交一段数据库查询代码,根据程序返回的结果,获得某些他想得知的数据,这就是所谓的SQL Injection,即SQL注入。
SQL注入是从正常的WWW端口访问,而且表面看起来跟一般的Web页面访问没什么区别,所以目前市面的防火墙都不会对SQL注入发出警报,如果管理员没查看IIS日志的习惯,可能被入侵很长时间都不会发觉。
但是,SQL注入的手法相当灵活,在注入的时候会碰到很多意外的情况。能不能根据具体情况进行分析,构造巧妙的SQL语句,从而成功获取想要的数据,是高手与“菜鸟”的根本区别。
根据国情,国内的网站用ASP+Access或SQLServer的占70%以上,PHP+MySQ占L20%,其他的不足10%。在本文,我们从分入门、进阶至高级讲解一下ASP注入的方法及技巧,PHP注入的文章由NB联盟的另一位朋友zwell撰写,希望对安全工作者和程序员都有用处。了解 ASP注入的朋友也请不要跳过入门篇,因为部分人对注入的基本判断方法还存在误区。大家准备好了吗?Let's Go...
入 门 篇
如果你以前没试过SQL注入的话,那么第一步先把IE菜单=>工具=>Internet选项=>高级=>显示友好 HTTP 错误信息前面的勾去掉。否则,不论服务器返回什么错误,IE都只显示为HTTP 500服务器错误,不能获得更多的提示信息。
第一节、SQL注入原理
以下我们从一个网站www.mytest.com开始(注:本文发表前已征得该站站长同意,大部分都是真实数据)。
在网站首页上,有名为“IE不能打开新窗口的多种解决方法”的链接,地址为:http://www.mytest.com/showdetail.asp?id=49,我们在这个地址后面加上单引号’,服务器会返回下面的错误提示:
Microsoft JET Database Engine 错误 '80040e14'
字符串的语法错误 在查询表达式 'ID=49'' 中。
/showdetail.asp,行8
从这个错误提示我们能看出下面几点:
1. 网站使用的是Access数据库,通过JET引擎连接数据库,而不是通过ODBC。
2. 程序没有判断客户端提交的数据是否符合程序要求。
3. 该SQL语句所查询的表中有一名为ID的字段。
从上面的例子我们可以知道,SQL注入的原理,就是从客户端提交特殊的代码,从而收集程序及服务器的信息,从而获取你想到得到的资料。
第二节、判断能否进行SQL注入
看完第一节,有一些人会觉得:我也是经常这样测试能否注入的,这不是很简单吗?
其实,这并不是最好的方法,为什么呢?
首先,不一定每台服务器的IIS都返回具体错误提示给客户端,如果程序中加了cint(参数)之类语句的话,SQL注入是不会成功的,但服务器同样会报错,具体提示信息为处理 URL 时服务器上出错。请和系统管理员联络。
其次,部分对SQL注入有一点了解的程序员,认为只要把单引号过滤掉就安全了,这种情况不为少数,如果你用单引号测试,是测不到注入点的
那么,什么样的测试方法才是比较准确呢?答案如下:
① http://www.mytest.com/showdetail.asp?id=49
② http://www.mytest.com/showdetail.asp?id=49 ;and 1=1
③ http://www.mytest.com/showdetail.asp?id=49 ;and 1=2
这就是经典的1=1、1=2测试法了,怎么判断呢?看看上面三个网址返回的结果就知道了:
可以注入的表现:
① 正常显示(这是必然的,不然就是程序有错误了)
② 正常显示,内容基本与①相同
③ 提示BOF或EOF(程序没做任何判断时)、或提示找不到记录(判断了rs.eof时)、或显示内容为空(程序加了on error resume next)
不可以注入就比较容易判断了,①同样正常显示,②和③一般都会有程序定义的错误提示,或提示类型转换时出错。
当然,这只是传入参数是数字型的时候用的判断方法,实际应用的时候会有字符型和搜索型参数,我将在中级篇的“SQL注入一般步骤”再做分析。
第三节、判断数据库类型及注入方法
不同的数据库的函数、注入方法都是有差异的,所以在注入之前,我们还要判断一下数据库的类型。一般ASP最常搭配的数据库是Access和SQLServer,网上超过99%的网站都是其中之一。
怎么让程序告诉你它使用的什么数据库呢?来看看:
SQLServer有一些系统变量,如果服务器IIS提示没关闭,并且SQLServer返回错误提示的话,那可以直接从出错信息获取,方法如下:
http://www.mytest.com/showdetail.asp?id=49 ;and user>0
这句语句很简单,但却包含了SQLServer特有注入方法的精髓,我自己也是在一次无意的测试中发现这种效率极高的猜解方法。让我看来看看它的含义:首先,前面的语句是正常的,重点在and user>0,我们知道,user是SQLServer的一个内置变量,它的值是当前连接的用户名,类型为nvarchar。拿一个 nvarchar的值跟int的数0比较,系统会先试图将nvarchar的值转成int型,当然,转的过程中肯定会出错,SQLServer的出错提示是:将nvarchar值 ”abc” 转换数据类型为 int 的列时发生语法错误,呵呵,abc正是变量user的值,这样,不废吹灰之力就拿到了数据库的用户名。在以后的篇幅里,大家会看到很多用这种方法的语句。
顺便说几句,众所周知,SQLServer的用户sa是个等同Adminstrators权限的角色,拿到了sa权限,几乎肯定可以拿到主机的 Administrator了。上面的方法可以很方便的测试出是否是用sa登录,要注意的是:如果是sa登录,提示是将”dbo”转换成int的列发生错误,而不是”sa”。
如果服务器IIS不允许返回错误提示,那怎么判断数据库类型呢?我们可以从Access和SQLServer和区别入手,Access和 SQLServer都有自己的系统表,比如存放数据库中所有对象的表,Access是在系统表[msysobjects]中,但在Web环境下读该表会提示“没有权限”,SQLServer是在表[sysobjects]中,在Web环境下可正常读取。
在确认可以注入的情况下,使用下面的语句:
http://www.mytest.com/showdetail.asp?id=49 ;and (select count(*) from sysobjects)>0
http://www.mytest.com/showdetail.asp?id=49 ;and (select count(*) from msysobjects)>0
如果数据库是SQLServer,那么第一个网址的页面与原页面http://www.mytest.com/showdetail.asp?id= 49是大致相同的;而第二个网址,由于找不到表msysobjects,会提示出错,就算程序有容错处理,页面也与原页面完全不同。
如果数据库用的是Access,那么情况就有所不同,第一个网址的页面与原页面完全不同;第二个网址,则视乎数据库设置是否允许读该系统表,一般来说是不允许的,所以与原网址也是完全不同。大多数情况下,用第一个网址就可以得知系统所用的数据库类型,第二个网址只作为开启IIS错误提示时的验证。
进 阶 篇
在入门篇,我们学会了SQL注入的判断方法,但真正要拿到网站的保密内容,是远远不够的。接下来,我们就继续学习如何从数据库中获取想要获得的内容,首先,我们先看看SQL注入的一般步骤:
第一节、SQL注入的一般步骤
首先,判断环境,寻找注入点,判断数据库类型,这在入门篇已经讲过了。
其次,根据注入参数类型,在脑海中重构SQL语句的原貌,按参数类型主要分为下面三种:
(A) ID=49 这类注入的参数是数字型,SQL语句原貌大致如下: Select * from 表名 where 字段=49 注入的参数为ID=49 And [查询条件],即是生成语句: Select * from 表名 where 字段=49 And [查询条件]
(B) Class=连续剧 这类注入的参数是字符型,SQL语句原貌大致概如下: Select * from 表名 where 字段=’连续剧’ 注入的参数为Class=连续剧’ and [查询条件] and ‘’=’ ,即是生成语句: Select * from 表名 where 字段=’连续剧’ and [查询条件] and ‘’=’’
© 搜索时没过滤参数的,如keyword=关键字,SQL语句原貌大致如下: Select * from 表名 where 字段like ’%关键字%’ 注入的参数为keyword=’ and [查询条件] and ‘%25’=’, 即是生成语句: Select * from 表名 where字段like ’%’ and [查询条件] and ‘%’=’%’
接着,将查询条件替换成SQL语句,猜解表名,例如:
ID=49 And (Select Count(*) from Admin)>=0
如果页面就与ID=49的相同,说明附加条件成立,即表Admin存在,反之,即不存在(请牢记这种方法)。如此循环,直至猜到表名为止。
表名猜出来后,将Count(*)替换成Count(字段名),用同样的原理猜解字段名。
有人会说:这里有一些偶然的成分,如果表名起得很复杂没规律的,那根本就没得玩下去了。说得很对,这世界根本就不存在100%成功的黑客技术,苍蝇不叮无缝的蛋,无论多技术多高深的黑客,都是因为别人的程序写得不严密或使用者保密意识不够,才有得下手。
有点跑题了,话说回来,对于SQLServer的库,还是有办法让程序告诉我们表名及字段名的,我们在高级篇中会做介绍。
最后,在表名和列名猜解成功后,再使用SQL语句,得出字段的值,下面介绍一种最常用的方法-Ascii逐字解码法,虽然这种方法速度很慢,但肯定是可行的方法。
我们举个例子,已知表Admin中存在username字段,首先,我们取第一条记录,测试长度:
http://www.mytest.com/showdetail.asp?id=49 ;and (select top 1 len(username) from Admin)>0
先说明原理:如果top 1的username长度大于0,则条件成立;接着就是>1、>2、>3这样测试下去,一直到条件不成立为止,比如>7成立,>8不成立,就是len(username)=8
当然没人会笨得从0,1,2,3一个个测试,怎么样才比较快就看各自发挥了。在得到username的长度后,用mid(username,N,1)截取第N位字符,再asc(mid(username,N,1))得到ASCII码,比如:
id=49 and (select top 1 asc(mid(username,1,1)) from Admin)>0
同样也是用逐步缩小范围的方法得到第1位字符的ASCII码,注意的是英文和数字的ASCII码在1-128之间,可以用折半法加速猜解,如果写成程序测试,效率会有极大的提高。
第二节、SQL注入常用函数
有SQL语言基础的人,在SQL注入的时候成功率比不熟悉的人高很多。我们有必要提高一下自己的SQL水平,特别是一些常用的函数及命令。
Access:asc(字符) SQLServer:unicode(字符)
作用:返回某字符的ASCII码
Access:chr(数字) SQLServer:nchar(数字)
作用:与asc相反,根据ASCII码返回字符
Access:mid(字符串,N,L) SQLServer:substring(字符串,N,L)
作用:返回字符串从N个字符起长度为L的子字符串,即N到N+L之间的字符串
Access:abc(数字) SQLServer:abc (数字)
作用:返回数字的绝对值(在猜解汉字的时候会用到)
Access:A between B And C SQLServer:A between B And C
作用:判断A是否界于B与C之间
第三节、中文处理方法
在注入中碰到中文字符是常有的事,有些人一碰到中文字符就想打退堂鼓了。其实只要对中文的编码有所了解,“中文恐惧症”很快可以克服。
先说一点常识:
Access中,中文的ASCII码可能会出现负数,取出该负数后用abs()取绝对值,汉字字符不变。
SQLServer中,中文的ASCII为正数,但由于是UNICODE的双位编码,不能用函数ascii()取得ASCII码,必须用函数unicode ()返回unicode值,再用nchar函数取得对应的中文字符。
了解了上面的两点后,是不是觉得中文猜解其实也跟英文差不多呢?除了使用的函数要注意、猜解范围大一点外,方法是没什么两样的。
高 级 篇
看完入门篇和进阶篇后,稍加练习,破解一般的网站是没问题了。但如果碰到表名列名猜不到,或程序作者过滤了一些特殊字符,怎么提高注入的成功率?怎么样提高猜解效率?请大家接着往下看高级篇。
第一节、利用系统表注入SQLServer数据库
SQLServer是一个功能强大的数据库系统,与操作系统也有紧密的联系,这给开发者带来了很大的方便,但另一方面,也为注入者提供了一个跳板,我们先来看看几个具体的例子:
① http://Site/url.asp?id=1;exec master..xp_cmdshell “net user name password /add”--
分号;在SQLServer中表示隔开前后两句语句,--表示后面的语句为注释,所以,这句语句在SQLServer中将被分成两句执行,先是Select出ID=1的记录,然后执行存储过程xp_cmdshell,这个存储过程用于调用系统命令,于是,用net命令新建了用户名为name、密码为password的windows的帐号,接着:
② http://Site/url.asp?id=1;exec master..xp_cmdshell “net localgroup name administrators /add”--
将新建的帐号name加入管理员组,不用两分钟,你已经拿到了系统最高权限!当然,这种方法只适用于用sa连接数据库的情况,否则,是没有权限调用xp_cmdshell的。
③ http://Site/url.asp?id=1 ;and db_name()>0
前面有个类似的例子and user>0,作用是获取连接用户名,db_name()是另一个系统变量,返回的是连接的数据库名。
④ http://Site/url.asp?id=1;backup database 数据库名 to disk=’c:\inetpub\wwwroot\1.db’;--
这是相当狠的一招,从③拿到的数据库名,加上某些IIS出错暴露出的绝对路径,将数据库备份到Web目录下面,再用HTTP把整个数据库就完完整整的下载回来,所有的管理员及用户密码都一览无遗!在不知道绝对路径的时候,还可以备份到网络地址的方法(如\\202.96.xx.xx\Share \1.db),但成功率不高。
⑤ http://Site/url.asp?id=1 ;and (Select Top 1 name from sysobjects where xtype=’U’ and status>0)>0
前面说过,sysobjects是SQLServer的系统表,存储着所有的表名、视图、约束及其它对象,xtype=’U’ and status>0,表示用户建立的表名,上面的语句将第一个表名取出,与0比较大小,让报错信息把表名暴露出来。第二、第三个表名怎么获取?还是留给我们聪明的读者思考吧。
⑥ http://Site/url.asp?id=1 ;and (Select Top 1 col_name(object_id(‘表名’),1) from sysobjects)>0
从⑤拿到表名后,用object_id(‘表名’)获取表名对应的内部ID,col_name(表名ID,1)代表该表的第1个字段名,将1换成2,3,4...就可以逐个获取所猜解表里面的字段名。
以上6点是我研究SQLServer注入半年多以来的心血结晶,可以看出,对SQLServer的了解程度,直接影响着成功率及猜解速度。在我研究SQLServer注入之后,我在开发方面的水平也得到很大的提高,呵呵,也许安全与开发本来就是相辅相成的吧。
第二节、绕过程序限制继续注入
在入门篇提到,有很多人喜欢用’号测试注入漏洞,所以也有很多人用过滤’号的方法来“防止”注入漏洞,这也许能挡住一些入门者的攻击,但对SQL注入比较熟悉的人,还是可以利用相关的函数,达到绕过程序限制的目的。
在“SQL注入的一般步骤”一节中,我所用的语句,都是经过我优化,让其不包含有单引号的;在“利用系统表注入SQLServer数据库”中,有些语句包含有’号,我们举个例子来看看怎么改造这些语句:
简单的如where xtype=’U’,字符U对应的ASCII码是85,所以可以用where xtype=char(85)代替;如果字符是中文的,比如where name=’用户’,可以用where name=nchar(29992)+nchar(25143)代替。
第三节、经验小结
1.有些人会过滤Select、Update、Delete这些关键字,但偏偏忘记区分大小写,所以大家可以用selecT这样尝试一下。
2.在猜不到字段名时,不妨看看网站上的登录表单,一般为了方便起见,字段名都与表单的输入框取相同的名字。
3.特别注意:地址栏的+号传入程序后解释为空格,%2B解释为+号,%25解释为%号,具体可以参考URLEncode的相关介绍。
4.用Get方法注入时,IIS会记录你所有的提交字符串,对Post方法做则不记录,所以能用Post的网址尽量不用Get。
5. 猜解Access时只能用Ascii逐字解码法,SQLServer也可以用这种方法,只需要两者之间的区别即可,但是如果能用SQLServer的报错信息把值暴露出来,那效率和准确率会有极大的提高。
防 范 方 法
SQL注入漏洞可谓是“千里之堤,溃于蚁穴”,这种漏洞在网上极为普遍,通常是由于程序员对注入不了解,或者程序过滤不严格,或者某个参数忘记检查导致。在这里,我给大家一个函数,代替ASP中的Request函数,可以对一切的SQL注入Say NO,函数如下:
Function SafeRequest(ParaName,ParaType) '--- 传入参数 --- 'ParaName:参数名称-字符型 'ParaType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)
Dim ParaValue ParaValue=Request(ParaName) If ParaType=1 then If not isNumeric(ParaValue) then Response.write "参数" & ParaName & "必须为数字型!" Response.end End if Else ParaValue=replace(ParaValue,"'","''") End if SafeRequest=ParaValue End function
这是一个用asp.net写的论坛程序,虽然简单但可以运行。
这个程序的编程思想其实还是基本延续了asp的方式,如果让那只大鸟儿看见可能要嘘之以鼻。但实际上这种方式对于asp程序向asp.net的快速移植还是有用的。如果你对这种移植不屑那也没办法,这个贴子就算给asp.net刚入门的小虾们开开眼。
这个例子包含3部分
1)forum.aspx-论坛主页。
2)reply.aspx-当在论坛主页中点击一个贴子时调用,显示贴子详细内容。
3)postmessage.aspx-上贴时调用,将内容保存入数据库
数据库结构 Table - newpost :This table will contain the New Topic posted messages postid (primary key) The unique id for each new topic. name The name of the author of the message. email E-mail address of the author. subject Subject of the message. ip IP address of the author. date Date / Time of the Post message Message posted. replies Number of replies to the post (if any) views Number of times the message has been viewed.
Table - reply :This table will contain the Replies made to the new topics. replyid (primary key) The unique id for each reply. name Name of the author. email E-mail address of the author. subject Subject of the post ip IP of the author. date Date / Time of post. message Message posted. postid postid from the "newpost" table for which this message is a reply.
用asp.net写的论坛程序--论坛主页
1) forum.aspx :- The main forum page
<%@ Page Language="C#" Debug="true" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="System.Data.ADO" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System" %> <html><head> <title>Welcome to My Forum!</title> <script language="C#" runat="server" > //execute this script when the page loads void Page_Load(Object Src, EventArgs E) { //Call the Method to DataBind the DataGrid Binding() ; } //This Method Connects to the Database, and DataBinds the Database to the DataGrid public void Binding() { //String to connect to the database, If your Database is in some other directory then change the path //To the Database below string strConn=@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\db\\board.mdb") ; //Make a Connection to the Database ADOConnection myConn = new ADOConnection(strConn) ; //String to select records from the Database. newpost Table //I have used "ORDER BY postid DESC" since I want to show the latest post on the top //If you remove this clause then the oldest message will be shown first string strCom = "SELECT postid ,subject ,name ,replies ,views ,date FROM newpost ORDER BY postid DESC" ; //Open the Connection, Always remember to Open the connection before doing anything else myConn.Open(); DataSet myDataSet = new DataSet(); //Create a ADODataSetCommand and a DataSet ADODataSetCommand myCommand =new ADODataSetCommand(strCom,myConn); //Fill the DataSet myCommand.FillDataSet(myDataSet,"newpost") ; //Connection is closed myConn.Close(); //Set the DataView of the Table "newpost" contained in the DataSet for the DataGrid DataGrid1.DataSource = myDataSet.Tables["newpost"].DefaultView ; //DataBind the DataGrid DataGrid1.DataBind(); } //This method is called when the DataGrid is Paged (i.e. when you change from Page 1 to Page 2 etc.. ) public void DataGrid_Updt(Object sender, DataGridPageChangedEventArgs e) { //Call the Method to Databind Binding(); } //This Method is called when the form is submitted to make a new Post public void Submit_Click(Object sender, EventArgs e) { //proceed only if all the required fields are filled-in if(Page.IsValid&&name.Text!=""&&subject.Text!=""&&email.Text!=""){ //Get the Current Date and Time DateTime now = DateTime.Now ; errmess.Text="" ; //I am building a custom query which will be used to call the postmessage.aspx page. //Since it will be a query we have to encode the query into UTF8 format. //So I get all the fields from the form and encode them into UTF8 format string req = "name="+ System.Web.HttpUtility.UrlEncodeToString(name.Text, System.Text.Encoding.UTF8); req+="&&email="+ System.Web.HttpUtility.UrlEncodeToString(email.Text, System.Text.Encoding.UTF8); req+="&&subject="+ System.Web.HttpUtility.UrlEncodeToString(subject.Text, System.Text.Encoding.UTF8); //Get the HostAddress of the Author req+="&&ip="+ System.Web.HttpUtility.UrlEncodeToString(Request.UserHostAddress.ToString(), System.Text.Encoding.UTF8); req+="&&date="+ System.Web.HttpUtility.UrlEncodeToString(now.ToString(), System.Text.Encoding.UTF8); req+="&&message="+ System.Web.HttpUtility.UrlEncodeToString(message.Text, System.Text.Encoding.UTF8); //A 'yes' is used below to tell the postmessage page that this is a new topic post req+="&&newpost="+ System.Web.HttpUtility.UrlEncodeToString("yes", System.Text.Encoding.UTF8); //call the postmessage.aspx page and append the query to it. Page.Navigate("postmessage.aspx?" + req); } else { errmess.Text="Fill in all the Required Fields before Posting!<br>" ; } } </script> <LINK href="mystyle.css" type=text/css rel=stylesheet></head> <body topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0"> <!-- #Include File="header.inc" --> <center> <asp:label id="errmess" text="" style="COLOR:#ff0000" runat="server" /> <asp:Label class=fodark text="<font color=#00000 >Welcome to My Discussion Forum</font>" runat=server /> <br> <br> <form method="post" runat="server" ID=Form1> <%-- The DataGrid settings. Its very interesting how much you can play with it --%> <asp:DataGrid id=DataGrid1 runat="server" ForeColor="Black" PagerStyle-Mode="NumericPages" OnPageIndexChanged="DataGrid_Updt" PageSize="20" AllowPaging="True" width="80%" autogeneratecolumns="False"> <property name="PagerStyle"> <asp:DataGridPagerStyle BackColor="Coral" Mode="NumericPages"> </asp:DataGridPagerStyle> </property>
<property name="AlternatingItemStyle"> <asp:TableItemStyle BorderColor="#FFC080" BackColor="#FF9966"> </asp:TableItemStyle> </property>
<property name="FooterStyle"> <asp:TableItemStyle ForeColor="White" BackColor="DarkOrange"> </asp:TableItemStyle> </property>
<property name="ItemStyle"> <asp:TableItemStyle BackColor="Moccasin"> </asp:TableItemStyle> </property>
<property name="HeaderStyle"> <asp:TableItemStyle Font-Bold="True" ForeColor="White" BackColor="Coral"> </asp:TableItemStyle> </property> <%-- I am setting up the Individual columns myself using Templates --%> <property name="Columns"> <%-- Manipulate the subject entry so that it contains a link to the reply page --%> <asp:TemplateColumn HeaderText="Subject" itemstyle-width=50%> <template name="ItemTemplate" > <asp:Label runat="server" Text='<%#"<a href=reply.aspx?postid="+DataBinder.Eval(Container, "DataItem.postid")+">" +DataBinder.Eval(Container, "DataItem.subject")+"</a>" %>' ID=Label2></asp:Label> </template> </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Author Name" itemstyle-width=20%> <template name="ItemTemplate"> <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.name") %>' ID=Label3></asp:Label> </template> </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Replies" itemstyle-width=10%> <template name="ItemTemplate"> <asp:Label runat="server" width=10% Text='<%# DataBinder.Eval(Container, "DataItem.replies") %>' ID=Label4> </asp:Label> </template> </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Views" itemstyle-width=10%> <template name="ItemTemplate"> <asp:Label runat="server" width=10% Text='<%# DataBinder.Eval(Container, "DataItem.views") %>' ID=Label5> </asp:Label> </template> </asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Date of Post" itemstyle-width=10%> <template name="ItemTemplate"> <asp:Label runat="server" width=10% Text=' <%# DataBinder.Eval(Container, "DataItem.date").ToString().ToDateTime().ToShortDateString() %>' ID=Label6> </asp:Label>
</template> </asp:TemplateColumn> </property> </asp:DataGrid> <br> <br> <asp:Label class=fodark text="<font color=#00000 >Post New Topic</font>" runat=server /> <br> <table border="0" width="80%" align="center"> <tr > <td class="fohead" colspan=2><b>Post New Topic</b></td> </tr> <tr class="folight" > <td>Name :</td> <td ><asp:textbox text="" id="name" runat="server" /> <font color=#ff0000>*</font></td> </tr> <tr class="folight"> <td>E-Mail :</td> <td><asp:textbox text="" id="email" runat="server"/> <font color=#ff0000>*</font></td> </tr> <tr class="folight"> <td> Subject:</td> <td><asp:textbox test="" id="subject" width=200 runat="server"/> <font color=#ff0000>*</font> </td></tr> <tr class="folight"> <td>Message :</td> <td> <asp:TextBox id=message runat="server" Columns="30" Rows="15" TextMode="MultiLine"></asp:TextBox></td> </tr> <tr class=folight> <td colspan=2> <asp:Button class=fodark id=write onClick=Submit_Click runat="server" Text="Submit"></asp:Button></td></tr> </table> </form> </center> <!-- #Include File="footer.inc" --> </body></html>
用asp.net写的论坛程序--浏览贴子内容及回复
2) reply.aspx : The topic viewing and replying page
<%@ Page Language="C#" EnableSessionState="False" Debug="True" %> <%@ Import Namespace="System" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.ADO" %> <html><head> <title>Post New Topic.</title> <%-- These are the imported assemblies and namespaces needed --%> <script Language="C#" runat="server"> DataSet ds ,rs; DataRow dr ; string postid ; public void Page_Load(object sender , EventArgs e) { //Check if the page is Post Back if(!Page.IsPostBack) { //Get the postid from the Query string postid = Request.Params["postid"] ; if(postid!=null) { //Database connection string. Change the path to the database file if you have some other path where //you are saving your Database file string strConn=@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\db\\board.mdb") ; //Make a connection to the Database ADOConnection myConn = new ADOConnection(strConn) ; //string to select the records from the newpost table string strCon ="SELECT subject, name, email, message ,date FROM newpost WHERE postid="+postid ; //set a ADODataSetCommand ADODataSetCommand myCommand =new ADODataSetCommand(strCon,myConn); ds = new DataSet(); //Don't ever forget to open the Connection myConn.Open(); //Fill the DataSet myCommand.FillDataSet(ds,"newpost") ; //Get the Row at position '0' and store it in a DataRow object //Why row at position '0' ? Since there can only be one record with the given postid remember !! //Why put into a DataRow ? Its easy to access data from a DataRow dr = ds.Tables["newpost"].Rows[0] ; //Get the "subject" from the DataRow and set it up in the post reply form's subject field subject.Text="Re:"+dr["subject"].ToString() ; //Select the replies to the post from the reply table strCon ="SELECT name , email, subject, message ,date FROM reply WHERE postid="+postid ; //Make a new ADODataSetCommand and DataSet for the reply table ADODataSetCommand myCommand2 =new ADODataSetCommand(strCon,myConn); rs = new DataSet() ; //fill the DataSet myCommand2.FillDataSet(rs, "reply") ; //Code to update the "views" field for the newpost Table //Select the views field from the table for a given postid strCon ="SELECT views FROM newpost WHERE postid = "+postid ; //Make a ADOCommand here since we want a ADODataReader later ADOCommand vicomm = new ADOCommand(strCon, myConn) ; ADODataReader reader ; //execute the statement and create a ADODataReader vicomm.Execute(out reader) ; //Read the First record (there can only be one record remember !) reader.Read() ; //Get a "Int32" value from the first Column (we have one column in the reader, check the select statement above) int i = reader.GetInt32(0) ; //Increase the views count i++ ; reader.Close() ; //Update the newpost table with the new views value strCon ="UPDATE newpost SET views = "+i+" WHERE (postid= "+postid+")" ; //since we are using the same ADOCOmmand object for this statement too to set the CommandText property vicomm.CommandText = strCon ; //Since this statement will result in no output we use "ExecuteNonQuery()" method vicomm.ExecuteNonQuery() ; //close the connection myConn.Close(); } } } // This method is called when the submit button is clicked public void Submit_Click(Object sender, EventArgs e) { //Get the postid postid = Request.Params["postid"] ;
//proceed only if all the required fields are filled-in if(Page.IsValid&&name.Text!=""&&subject.Text!=""&&email.Text!=""){ DateTime now = DateTime.Now ; errmess.Text="" ; //We have to call the postmessage.aspx page with a query to post the data to the Database. //Hence we have to first build the custom query from the Data posted by the user //also since we are using a query we have to encode the data into UTF8 format string req = "name="+ System.Web.HttpUtility.UrlEncodeToString(name.Text, System.Text.Encoding.UTF8); req+="&&email="+ System.Web.HttpUtility.UrlEncodeToString(email.Text, System.Text.Encoding.UTF8); req+="&&subject="+System.Web.HttpUtility.UrlEncodeToString(subject.Text, System.Text.Encoding.UTF8); req+="&&ip="+System.Web.HttpUtility.UrlEncodeToString(Request.UserHostAddress.ToString(), System.Text.Encoding.UTF8); req+="&&date="+ System.Web.HttpUtility.UrlEncodeToString(now.ToString(), System.Text.Encoding.UTF8); req+="&&message="+ System.Web.HttpUtility.UrlEncodeToString(message.Text, System.Text.Encoding.UTF8); //Encode "no" to indicate that the post is not a new post but its a reply to a earlier message req+="&&newpost="+ System.Web.HttpUtility.UrlEncodeToString("no", System.Text.Encoding.UTF8); req+="&&previd="+ System.Web.HttpUtility.UrlEncodeToString(postid, System.Text.Encoding.UTF8); //Call the postmessage page with our custom query Page.Navigate("postmessage.aspx?" + req); } else { errmess.Text="Fill in all the Required Fields !" ; } } </script> <LINK href="mystyle.css" type=text/css rel=stylesheet></head> <body topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0"> <%-- Include a header file 'header.inc' --%> <!-- #Include File="header.inc" --> <br> <div align=center> <table border=0 width=80% cellspacing=2> <tr class=fohead><th width=20%>Author Name</th> <th width=80%>Message</th></tr> <%-- Below I am encapsulating the email of the author over the name of the author so that when you click on the author a e-mail gets sent to him Also I am geting the DateTime from the DataBase and Displaying the Date and Time separately --%> <tr class=folight><td rowspan=2 align="center"><%= "<a href=mailto:"+dr["email"]+">"+dr["name"]+"</a>" %><br> <font size=1><%= dr["date"].ToString().ToDateTime().ToShortDateString() %><br> <%= dr["date"].ToString().ToDateTime().ToShortTimeString() %></font> </td> <td><b>Subject: </b><%=dr["subject"] %></td></tr> <tr class=folight> <td><pre><%=dr["message"] %></pre> </td> </tr> <%-- Get all the replies to the Original post and show them --%> <% int no = rs.Tables["reply"].Rows.Count ; if(no>0) { for(int j=0 ;j<no ; j++) { DataRow rd = rs.Tables["reply"].Rows[j] ; %> <tr class=fodark> <td align="center"><%="<a href=mailto:"+rd["email"]+">"+rd["name"]+"</a>" %><br> <font size=1><%= rd["date"].ToString().ToDateTime().ToShortDateString() %><br> <%= rd["date"].ToString().ToDateTime().ToShortTimeString() %></font> </td> <td><pre><%=rd["message"] %></pre> </td> </tr> <% } } %> </table> </div> <h3 align="center" class="fodark"><a href=forum.aspx>Click Here</a> to go to back to Forum. <br>Reply to the Above Post.</h3> <br> <asp:label id="errmess" text="" style="COLOR:#ff0000" runat="server" /> <form runat="server"> <table border="0" width="80%" align="center"> <tr > <td class="fohead" colspan=2><b>Reply to the Post</b></td> </tr> <tr class="folight" > <td>Name :</td> <td ><asp:textbox text="" id="name" runat="server" /> <font color=#ff0000>*</font></td> </tr> <tr class="folight"> <td>E-Mail :</td> <td><asp:textbox text="" id="email" runat="server"/> <font color=#ff0000>*</font></td> </tr> <tr class="folight"> <td> Subject:</td> <td><asp:textbox test="" id="subject" width=200 runat="server"/> <font color=#ff0000>*</font> </td></tr> <tr class="folight"> <td>Message :</td> <td> <asp:TextBox id=message runat="server" Columns="30" Rows="15" TextMode="MultiLine"></asp:TextBox></td> </tr> <tr class=folight> <td colspan=2> <asp:Button class=fodark id=write onClick=Submit_Click runat="server" Text="Submit"></asp:Button></td></tr> </table> </form><br> <br><!-- #Include File="footer.inc" --> </body></html>
用asp.net写的论坛程序--上贴保存
3) postmessage.aspx :- The page which saved data to the Database
<%@ Import Namespace="System" %> <%@ Assembly Name="System.Data" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.ADO" %> <%@ Page Language="C#" Debug="true" %> <html> <head> <title>Thank You for Posting !</title> <script language="C#" runat="server" > //execute this script when the page loads void Page_Load(Object Src, EventArgs E) { //if the page is called from another page if (!Page.IsPostBack) { //Get all the Parameters from the Query string string name = Request.Params["name"] ; string email = Request.Params["email"] ; string subject = Request.Params["subject"] ; string ip = Request.Params["ip"] ; string date = Request.Params["date" ]; string message = Request.Params["message"] ; bool newmess =true ; string previd ="1"; //Check if the post is a New topic or a reply to a new topic if(Request.Params["newpost"].Equals("no")) { //if its a reply then get the postid called as previd here newmess =false ; previd = Request.Params["previd"] ; } //If the post is a new topic then follow the below routine if(newmess) { //The string for the path to the database , if your database is in some other directory then edit the path //of this variable string strConn=@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source= "+Server.MapPath(".\\db\\board.mdb") ; //Get a ADOConnection to the database ADOConnection myConn = new ADOConnection(strConn) ; //The SQL Select statement string strCom = "Select postid from newpost" ; //Create a ADOCommand since we want a ADODataReader later ADOCommand myCommand =new ADOCommand(strCom,myConn); //Open the connection myConn.Open(); ADODataReader reader; //Execute the command and get the Data into "reader" myCommand.Execute(out reader) ; int i=1 ; //Get the current number of records present in the database. while(reader.Read()) { i++ ; } reader.Close() ; //build the SQL statement to insert into the Database string insertStr =" INSERT INTO newpost VALUES (" +i +", '" +name+"', '" +email+"', '" +subject+"', '" +ip+"', '" +date+"', '" +message+"',0, 0)" ; myCommand.CommandText =insertStr ; //Since the SQL statement does not return any output use "ExecuteNonQuery() method myCommand.ExecuteNonQuery() ; //Close the connection myConn.Close() ; } else { //If the posted data is a reply to a topic then follow the below procedure //string for the path to the database, if your database is stored in some other directory then //edit the path here string strConn=@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+ Server.MapPath(".\\db\\board.mdb") ; ADOConnection myConn = new ADOConnection(strConn) ; //SQL statement to select the replyid string strCom = "Select replyid from reply" ; //create a ADOCommand ADOCommand myCommand =new ADOCommand(strCom,myConn); //Open the Connection myConn.Open(); ADODataReader reader; //Execute the command and get the Data into "reader" myCommand.Execute(out reader) ; int i=1 ; //Get the current number of records present in the database. while(reader.Read()) { i++ ; } reader.Close() ; //Build a statement to insert the values into the reply table string insertStr =" INSERT INTO reply VALUES (" +i +", '" +name+"', '" +email+"', '" +subject+"', '" +ip+"', '" +date+"', '" +message+"', " +previd+")"; myCommand.CommandText =insertStr ; //ExecuteNonQuery - since the command does not return anything myCommand.ExecuteNonQuery() ; //string to get the replies column from the newpost table string replyno = "SELECT replies FROM newpost WHERE postid ="+previd ; myCommand.CommandText =replyno ; //Execute command and get the reader myCommand.Execute(out reader) ; //read the first record (remember there can only be one record in the reader since postid is unique) reader.Read(); //Get the "Int16" value of the number of replies from the replies column in the newpost table int rep =reader.GetInt16(0) ; reader.Close() ; rep++ ; //SQL statement to update the replies field in the newpost table string updtStr ="UPDATE newpost SET replies = "+rep +" WHERE (postid = "+previd+")" ; myCommand.CommandText = updtStr; //ExecuteNonQuerry why ?? I guess U should know by now ! myCommand.ExecuteNonQuery(); myConn.Close() ; } //get the different Parameters from the query string and store it //to respective Labels NameLabel.Text = name; EmailLabel.Text= email ; SubjectLabel.Text=subject; MessageLabel.Text=message ; } else { //else display an error errmess.Text="This Page Cannot be called directly. It has to be called from the Form posting page.<br>" ; } } </script> <LINK href="mystyle.css" type=text/css rel=stylesheet> </head> <body topmargin="0" leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0"> <!-- #Include File="header.inc" --> <center> <asp:label id="errmess" text="" style="color:#FF0000" runat="server" /> <h2 class="fodark"><b>Thank You , for posting on the Message Board.</b></h2> <table align=center width="60%" border="0" cellspacing="2" cellpadding="1" > <tr class="fohead"><td colspan="2">The information You Posted!</td></tr> <tr class="folight"> <td>Name :</td> <td><asp:label id="NameLabel" text="" runat="server" /></td> </tr> <tr class="folight"> <td>E-Mail :</td> <td><asp:label id="EmailLabel" text="" runat="server" /></td> </tr> <tr class="folight"> <td>Subject :</td> <td><asp:label id="SubjectLabel" text="" runat="server" /></td> </tr> <tr class="folight"> <td>Message :</td> <td><asp:label id="MessageLabel" text="" runat="server" /></td> </tr> </table> <br> <h4 class="fodark"><a href="forum.aspx">Click here </a> to go back to the Forum.<br> <%-- A little work to show the link to return back to the page if, the post was a reply --%> <% if(Request.Params["previd"]!=null) { %> <a href='reply.aspx?postid=<%=Request.Params["previd"] %>'> Click here </a>to go back where you came from. <% } %> </h4> </center> <!-- #Include File="footer.inc" --> </body> </html>
将sql中使用的一些特殊符号,如' -- /* ; %等用Replace()过滤; 2限制文本框输入字符的长度; 3检查用户输入的合法性;客户端与服务器端都要执行,可以使用正则。 4使用带参数的SQL语句形式。
ASP.NET中如何防范SQL注入式攻击
一、什么是SQL注入式攻击?
所谓SQL注入式攻击,就是攻击者把SQL命令插入到Web表单的输入域或页面请求的查询字符串,欺骗服务器执行恶意的SQL命令。在某些表单中,用户输入的内容直接用来构造(或者影响)动态SQL命令,或作为存储过程的输入参数,这类表单特别容易受到SQL注入式攻击。常见的SQL注入式攻击过程类如:
⑴ 某个ASP.NET Web应用有一个登录页面,这个登录页面控制着用户是否有权访问应用,它要求用户输入一个名称和密码。
⑵ 登录页面中输入的内容将直接用来构造动态的SQL命令,或者直接用作存储过程的参数。下面是ASP.NET应用构造查询的一个例子:
System.Text.StringBuilder query = new System.Text.StringBuilder( "SELECT * from Users WHERE login = '") .Append(txtLogin.Text).Append("' AND password='") .Append(txtPassword.Text).Append("'");
⑶ 攻击者在用户名字和密码输入框中输入"'或'1'='1"之类的内容。
⑷ 用户输入的内容提交给服务器之后,服务器运行上面的ASP.NET代码构造出查询用户的SQL命令,但由于攻击者输入的内容非常特殊,所以最后得到的SQL命令变成:SELECT * from Users WHERE login = '' or '1'='1' AND password = '' or '1'='1'。
⑸ 服务器执行查询或存储过程,将用户输入的身份信息和服务器中保存的身份信息进行对比。
⑹ 由于SQL命令实际上已被注入式攻击修改,已经不能真正验证用户身份,所以系统会错误地授权给攻击者。
如果攻击者知道应用会将表单中输入的内容直接用于验证身份的查询,他就会尝试输入某些特殊的SQL字符串篡改查询改变其原来的功能,欺骗系统授予访问权限。
系统环境不同,攻击者可能造成的损害也不同,这主要由应用访问数据库的安全权限决定。如果用户的帐户具有管理员或其他比较高级的权限,攻击者就可能对数据库的表执行各种他想要做的操作,包括添加、删除或更新数据,甚至可能直接删除表。
二、如何防范?
好在要防止ASP.NET应用被SQL注入式攻击闯入并不是一件特别困难的事情,只要在利用表单输入的内容构造SQL命令之前,把所有输入内容过滤一番就可以了。过滤输入内容可以按多种方式进行。
⑴ 对于动态构造SQL查询的场合,可以使用下面的技术:
第一:替换单引号,即把所有单独出现的单引号改成两个单引号,防止攻击者修改SQL命令的含义。再来看前面的例子,“SELECT * from Users WHERE login = ''' or ''1''=''1' AND password = ''' or ''1''=''1'”显然会得到与“SELECT * from Users WHERE login = '' or '1'='1' AND password = '' or '1'='1'”不同的结果。
第二:删除用户输入内容中的所有连字符,防止攻击者构造出类如“SELECT * from Users WHERE login = 'mas' -- AND password =''”之类的查询,因为这类查询的后半部分已经被注释掉,不再有效,攻击者只要知道一个合法的用户登录名称,根本不需要知道用户的密码就可以顺利获得访问权限。
第三:对于用来执行查询的数据库帐户,限制其权限。用不同的用户帐户执行查询、插入、更新、删除操作。由于隔离了不同帐户可执行的操作,因而也就防止了原本用于执行SELECT命令的地方却被用于执行INSERT、UPDATE或DELETE命令。
⑵ 用存储过程来执行所有的查询。SQL参数的传递方式将防止攻击者利用单引号和连字符实施攻击。此外,它还使得数据库权限可以限制到只允许特定的存储过程执行,所有的用户输入必须遵从被调用的存储过程的安全上下文,这样就很难再发生注入式攻击了。
⑶ 限制表单或查询字符串输入的长度。如果用户的登录名字最多只有10个字符,那么不要认可表单中输入的10个以上的字符,这将大大增加攻击者在SQL命令中插入有害代码的难度。
⑷ 检查用户输入的合法性,确信输入的内容只包含合法的数据。数据检查应当在客户端和服务器端都执行——之所以要执行服务器端验证,是为了弥补客户端验证机制脆弱的安全性。
在客户端,攻击者完全有可能获得网页的源代码,修改验证合法性的脚本(或者直接删除脚本),然后将非法内容通过修改后的表单提交给服务器。因此,要保证验证操作确实已经执行,唯一的办法就是在服务器端也执行验证。你可以使用许多内建的验证对象,例如RegularExpressionValidator,它们能够自动生成验证用的客户端脚本,当然你也可以插入服务器端的方法调用。如果找不到现成的验证对象,你可以通过CustomValidator自己创建一个。
⑸ 将用户登录名称、密码等数据加密保存。加密用户输入的数据,然后再将它与数据库中保存的数据比较,这相当于对用户输入的数据进行了“消毒”处理,用户输入的数据不再对数据库有任何特殊的意义,从而也就防止了攻击者注入SQL命令。System.Web.Security.FormsAuthentication类有一个HashPasswordForStoringInConfigFile,非常适合于对输入数据进行消毒处理。
⑹ 检查提取数据的查询所返回的记录数量。如果程序只要求返回一个记录,但实际返回的记录却超过一行,那就当作出错处理。
1将sql中使用的一些特殊符号,如' -- /* ; %等用Replace()过滤; 2限制文本框输入字符的长度; 3检查用户输入的合法性;客户端与服务器端都要执行,可以使用正则。 4使用带参数的SQL语句形式。
尽量用存储过程
<!-- 呵呵我发的上一版相信大家都看过了吧,想一想上一版的确是不怎么华丽,而且上一版是针对表格内的连接A而定位的 而这一版的优点显然比上一版要华丽,速度一样快,而且是针对表格TD来定位的,TIMEOUT设置的也必要合理 以下代码完整范例请登陆 http://www.lshdic.com 查看,或到 http://www.lshdic.com/editdhtml.asp 自行编辑测试 -->
<HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; Charset=gb2312"> <META name="GENERATOR" content="网络程序员伴侣-Lshdic 2002"> <META NAME ="KEYWORDS" CONTENT="lshdic,蓝丽网,html,css,javascript,vbscript,asp,sql,dhtml,vml,php,jsp,xml,vrml,vb,vc,delphi,开发,电脑,网络,编程,程序员,下载,软件,网页,编辑器,技术论坛"> <STYLE> a{text-Decoration:none;} a:hover{color:blue} td{font-size:12px;color:555555} .menu{border-right:0;border-top:0;border-bottom:0;border-left:1 solid white;color:666666} </STYLE> </HEAD> <BODY vlink=#6772CD link='#6772CD'> <!--导航栏正式制作开始--> <script> function window.onerror(){ return true //防止浏览器未下载完毕用户触发函数时出现错误提示 } </script>
<!--整个导航栏HTML制作开始,其中并调用MOVESE函数构造一级菜单--> <TABLE cellspacing=0 cellpadding=1 width=770 align=center style='border-width:0' bgcolor='BBE2F5' frame=below rules=none bordercolordark=white bordercolorlight=dddddd id=menutd onmouseover=over2() onmouseout=out2() onclick=click2()> <TR align=center style='cursor:hand;'> <td height=20 id=menutd1 style='border:1 solid white;border-top:0;border-bottom:1 solid eeeeee;' goto='index.asp' onmouseover="movese('返回蓝丽网主页|-|娱乐视听-Flash|娱乐视听-经典电影|技术文章库|下载中心|编辑网页|编写程序|Lshdic2002|留言我们|网友中心-网友软件|网友中心-网友网站|网友中心-网友人才|蓝丽网技术论坛','index.asp||happy.asp|happy2.asp|wenzhang.asp|download.asp|editweb.asp|editdhtml.asp|lshdic2002.asp|bbs2.asp|friendsoft.asp|friendweb.asp|friendabout.asp|bbs/')"> 回首页 </td> <td width=150 style='cursor:default;background-color:#BBE2F5;' id=menutd2 goto=''></td> <Td class=menu onmouseover="movese('FlashMtv 经典音乐|MTV专集 经典电影','happy.asp|happy2.asp')" goto='happy.asp'>娱乐视听</a> </td>
<!--这个菜单使用了二级菜单,稍微较长,请自行修改--> <Td class=menu onmouseover="movese('网络编程语言**Html**Css**JavaScript**VbScript**Dhtml**Vml**ActiveX**Asp**Php**Jsp**Sql+Ado**Xml+*.net**其他网络技术|软件编程语言**Basic+VB**C语言+VC+CB**Java+VJ+J2EE**Delphi**VFP+汇编+Dos+其他|-|其他非编程学术|蓝丽所有网友问题|查找所有技术文章','被屏蔽网址**wenzhang.asp?str=Html<font style=display:none>Dhtml&page=1**wenzhang.asp?str=Css&page=1**wenzhang.asp?str=JavaScript/Js<font style=display:none>Jsp&page=1**wenzhang.asp?str=Vbs&page=1**wenzhang.asp?str=Dhtml&page=1**wenzhang.asp?str=Vml&page=1**wenzhang.asp?str=ActiveX&page=1**wenzhang.asp?str=Asp&page=1**wenzhang.asp?str=Php&page=1**wenzhang.asp?str=Jsp&page=1**wenzhang.asp?str=Sql/Ado&page=1**wenzhang.asp?str=Xml/.Net/Xsl&page=1**wenzhang.asp?str=Fso/Wsh/Htc/正则/Object/iis/pws/Vrml&page=1|被屏蔽网址**wenzhang.asp?str=Basic/VB<font style=display:none>Vbs&page=1**wenzhang.asp?str=C语言/VC/CB&page=1**wenzhang.asp?str=VJ/J2EE/Java<font style=display:none>JavaScript&page=1**wenzhang.asp?str=Delphi&page=1**wenzhang.asp?str=PB/VF/汇编/单片机/苹果机/Dos&page=1||wenzhang.asp?str=英语/注册表:/微软/驱动程序/硬件/黑客/加密/解密/攻击/防御/入侵/红客/外语/业界/理论/趋势/破解/工作/程序员/设计师/新闻/社会/讲座/病毒/转载/原创&page=1|wenzhang.asp?str=请问/问题/难题/请教/帮忙/帮助/帮忙/sos/help/解决/有没有/帮帮/救命/救救/急/教我/愁/谁能/能不/可不可/行不/怎么/提问/怎样/才能/能让/没办法/过来/瞧一&page=1|bbs/instr.asp')" goto='wenzhang.asp'>技术文章 </td> <!--具有二级菜单效果的表格制作结束-->
<Td class=menu onmouseover="movese('进入下载中心|编程工具|电子教程|编程素材|Lshdic2002配套工具','download.asp|download.asp?screen=工具软件&page=1|download.asp?screen=电子教程&page=1|download.asp?screen=编程素材&page=1|download.asp?screen=LD配套工具&page=1')" goto='download.asp'>下载中心 </td> <Td class=menu onmouseover="movese('进入网页编辑中心|下载编辑网页v2版','editweb.asp|download2.asp?id=48')" goto='editweb.asp'>编辑网页 </td> <Td class=menu onmouseover="movese('进入程序编辑中心|下载编写程序v2版','editdhtml.asp|download2.asp?id=92',1000)" goto='editdhtml.asp'>编写程序 </td> <Td class=menu align=center title='进行注册,领取Lshdic200X软件序列号的地方' style='font-size:13px' onmouseover="movese('查看领取Lshdic序列号|注册购买Lshdic序列号|注册购买流程简介','lshdic2002.asp|lshdic2002one.asp|lshdic2002help1.asp')" goto='lshdic2002.asp'>Lshdic </td> <Td class=menu onmouseover="movese('查看客户所有留言|签写新留言','bbs2.asp|bbs2fatie.asp')" goto='bbs2.asp'>留言我们 </td> <Td class=menu onmouseover="movese('网 友 软 件|网 友 网 站|网 友 文 章|网 友 简 历|-|网 友 发 布 平 台','friendsoft.asp|friendweb.asp|friendword.asp|friendabout.asp||friendftp.asp',1000)" goto='friendall.asp'>网友中心 </td> <Td class=menu align=center onmouseover="movese('进入蓝丽技术论坛|-|网页版面美工设计|网页前台脚本编程|网页后台脚本编程|Xml与Net时代编程|软件开发交流论坛|讨论区及其他学术|-|会员登陆注册入口','bbs/||bbs/page.asp?dex=网页版面美工设计|bbs/page.asp?dex=网页前台脚本编程|bbs/page.asp?dex=网页后台脚本编程|bbs/page.asp?dex=Xml与Net时代编程|bbs/page.asp?dex=软件开发交流论坛|bbs/page.asp?dex=讨论区及其他学术||bbs/olduser.asp')" goto='bbs/'>技术论坛 </td></tr></TABLE> <!--基本导航栏HTML构造结束,以下开始着手编写构造MOVESE等等菜单显示,定位,消失的脚本-->
<script> var cleartime=1 function movese(menustr,menuhref){ //一级菜单的显示函数,menustr=菜单要显示的文本,menuhref=菜单文本对应的网址 happydiv.style.display=''; //首先显示的一级菜单 happydiv2.style.display='none'; //其次将以显示的二级菜单关闭 if(cleartime!=1)clearTimeout(cleartime) //触发此函数通常是在mouseover时,因此取消"定时关闭菜单"的定时器 happydiv.style.posLeft=menutd.offsetLeft+event.srcElement.offsetLeft; //一级菜单绝对位置"左"定位 happydiv.style.posTop=menutd.offsetTop+menutd.offsetHeight //一级菜单绝对位置"上"定位 for(i=0;happydiv.rows.length;i++)happydiv.deleteRow() //清除菜单中以有的TD表格数据 str1=menustr.split('|');str2=menuhref.split('|') //将menustr以"|"号分割为数组 for(i=0;i<str1.length;i++){ //循环显示数据数据开始 tdstr=happydiv.insertRow().insertCell() //首先在一级菜单中查入一个<Tr><Td></Td></Tr> if(str1[i].indexOf('**')==-1){ //如果是不构成显示二级菜单的数据,以**做判断 if(str1[i]!="-")tdstr.innerHTML="<a href='"+str2[i]+"'>"+str1[i]+"</a>";else tdstr.innerHTML="<hr size=1 color=#8BB4D9>" }else{ //如果是能构成二级菜单的数据则... str3=str1[i].split('**') //开始构件二级菜单驱动的显示字符 tdstr.innerHTML="<font onmouseover=movese2('"+str1[i]+"','"+str2[i].replace(/</g,"lshdicstr1").replace(/ /g,"lshdicstr2").replace(/>/g,"lshdicstr3")+"')>"+str3[0]+" →</font>" //MOVEOVER时调用二级菜单显示函数MOVESE2,replace是将指定网址中的特殊字符替换为预定字符 }} cleartime=setTimeout('happydiv.style.display="none";happydiv2.style.display="none"',2000) //一切完毕后加上定时关闭菜单,可选 } function movese2(menustr2,menuhref2){ //二级菜单的显示函数,menustr2=菜单要显示的文本,menuhref=菜单文本对应的网址 happydiv2.style.display=''; //第一步自然是先显示二级菜单的容器表格 if(cleartime!=1)clearTimeout(cleartime) //第二步自然是清除定时器关闭的设置 happydiv2.style.posLeft=happydiv.offsetLeft+happydiv.offsetWidth; //二级菜单定位"左" temptop1=event.srcElement.parentElement.parentElement happydiv2.style.posTop=happydiv.offsetTop+(temptop1.offsetHeight*temptop1.rowIndex) //二级菜单定位"上",根据一级菜单中单个TD的高度*第几个计算 for(i=0;happydiv2.rows.length;i++)happydiv2.deleteRow() //定位完毕,开始显示数据,首先要清除以显示的TD str3=menustr2.split('**');str4=menuhref2.split('**') //然后分解构成二级菜单的数据 for(i=1;i<str3.length;i++){ //按照数组的大小循环生成单个TD tdstr2=happydiv2.insertRow().insertCell() //在二级菜单中插入<Tr><Td></Td></Tr> tdstr2.innerHTML="<a href='"+str4[i].replace(/lshdicstr1/g,'<').replace(/lshdicstr2/g,' ').replace(/lshdicstr3/g,'>')+"'>"+str3[i]+"</a>" //设定具体显示的数据,replace将预定字符替换过来 } cleartime=setTimeout('happydiv.style.display="none";happydiv2.style.display="none"',2000) //一切完毕后加上定时关闭菜单,可选 } function over1(){ //一,二级菜单中MOVEOVER事件时使用本函数定义菜单效果 if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='eeeeee';event.srcElement.style.borderTop='1 solid'; event.srcElement.style.borderBottom='1 solid'}else if(event.srcElement.tagName=="FONT"||event.srcElement.tagName=="A"){ event.srcElement.parentElement.bgColor='eeeeee';event.srcElement.parentElement.style.borderTop='1 solid'; event.srcElement.parentElement.style.borderBottom='1 solid'} } function out1(){ //一,二级菜单中MOVEOUT事件时使用本函数定义菜单效果 if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='';event.srcElement.style.borderTop=''; event.srcElement.style.borderBottom='' }else if(event.srcElement.tagName=="FONT"||event.srcElement.tagName=="A"){event.srcElement.parentElement.bgColor=''; event.srcElement.parentElement.style.borderTop='';event.srcElement.parentElement.style.borderBottom=''} } function click1(){ //一,二级菜单时CLICK单击事件时使用本函数转到指定网址 if(event.srcElement.tagName=="TD")location.href=event.srcElement.all.tags('A')(0).href } function over2(){ //基本的HTML导航栏在MOUSEOVER时使用本函数,设定背景,并清除定时关闭 if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='white';if(cleartime!=1)clearTimeout(cleartime)} } function out2(){ //基本的HTML导航栏在MOUSEOUT时使用本函数,设定背景,并加上定时关闭菜单的效果 if(event.srcElement.tagName=="TD"){event.srcElement.bgColor=''; cleartime=setTimeout('happydiv.style.display="none";happydiv2.style.display="none"',500)} } function click2(){ //基本的HTML导航栏在CLICK单击时转到的网址,目标网址使用自定义的HTML属性GOTO做目标 location.href=event.srcElement.goto } function document.onclick(){ //页面单击时关闭所有菜单 happydiv.style.display='none';happydiv2.style.display='none' } </script> <table id=happydiv style='position:absolute;z-index:5;display:none;cursor:hand;border-top:0;border-bottom:0' bgcolor=white cellspacing=0 border=1 rules=none bordercolorlight=black bordercolordark=white onmouseover="over1();clearTimeout(cleartime)" onmouseout="out1();temp1='none';cleartime=setTimeout('happydiv.style.display=temp1;happydiv2.style.display=temp1',500)" onclick=click1()> <tr><Td></td></tr> </table> <!--一级容器菜单显示表格结束--> <table id=happydiv2 style='position:absolute;z-index:5;display:none;cursor:hand;border-left:0' bgcolor=white cellspacing=0 border=1 rules=none bordercolorlight=black bordercolordark=white onmouseover="over1();clearTimeout(cleartime)" onmouseout="out1();temp1='none';cleartime=setTimeout('happydiv.style.display=temp1;happydiv2.style.display=temp1',500)" onclick=click1()> <tr><Td></td></tr> </table> <!--二级扩展菜单显示表格结束-->
<!-- 整个程序就是这样的,乍看来乱不可言,细看来则条理清晰,非常实用,几乎没有多余代码,由于定义了函数,所以移植性和可塑性很强 其中数据为 - 相当于"WINDOWS菜单中的水平线" -->
树形图用于显示按照树形结构进行组织的数据,其用途比较广泛,如计算机中的文件系统(Windows中的资源管理器)、企业或公司的组成结构等。我们知道在Windows下VB、PB、Delphi等工具提供了一个功能很强的树型控件TreeView,利用Treeview控件可以方便地开发树形图。然而在网页上实现树形图就不那么容易了,现在在ASP.NET中利用微软提供的Internet Explorer WebControls它使得网页上的树形图开发与在Windows下一样的方便,一样的功能强大,甚至更灵活。
本文介绍用Internet Explorer WebControls开发树形图的方法,由于树形图结构较复杂,使用起来常不知如何下手。笔者结合最近刚为公司用ASP.NET编写的应用程序管理器这一具体实例,详细阐述在ASP.NET下如何将Internet Explorer WebControls的使用与数据库联系起来,实现数据分任意多层显示,方便地进行增加、修改、删除、移动操作。笔者希望通过对该实例的阐述,达到抛砖引玉的效果,与各位同仁相互交流,共同进步。
Internet Explorer WebControls不在VS.NET的标准Server Control中,要到微软的站点上下载,下载地址是:http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/ASP_DOT_NET_ServerControls/WebControls/default.asp 下载安装后第一次使用时,要右击工具箱Customize Toolbox…→.NET Framework Components中找到Micosoft.Web.UI.WebControls.Treeview后选中,这样Treeview控件就出现在工具箱中了。
一、树的建立
具体方法是:创建一个数据库,设计树图信息表TREE_INFO,包含NODEID、PARENTID、NODENAME、ADDERSS、ICON字段,其它字段根据实际业务而定,节点名称NODENAME将在树型控件的节点上显示,NODEID字段保存节点的唯一标识号,PARENTID表示当前节点的父节点号,标识号组成了一个“链表”,记录了树上节点的结构。设计一个Web窗体其上放置TreeView控件。
Private Sub CreateDataSet()’建立数据集 Dim myConn As New SqlConnection() Dim myCmd As New SqlCommand("select NODEID,NODENAME,PARENTID,ADDRESS,ICON from Tree_info", myConn) Dim myDataAdapter As New SqlDataAdapter() myConn.ConnectionString = Application("connectstring") myCmd.CommandText = "" myCmd.Connection = myConn myDataAdapter.SelectCommand = myCmd myDataAdapter.Fill(ds, "tree") End Sub
建树的基本思路是:从根节点开始递归调用显示子树
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CreateDataSet() intiTree(TreeView1.Nodes, 0) End Sub Private Sub intiTree(ByRef Nds As TreeNodeCollection, ByVal parentId As Integer) Dim dv As New DataView() Dim drv As DataRowView Dim tmpNd As TreeNode Dim intId As Integer dv.Table = ds.Tables("tree") dv.RowFilter = "PARENTID=’" & parentId & "’" For Each drv In dv tmpNd = New TreeNode() strId = drv("NODE_ID") tmpNd.ID = strId tmpNd.Text = drv("NODE_NAME ") tmpNd.ImageUrl = drv("ICON").ToString Nds.Add(tmpNd) intiTree(Nds(Nds.Count - 1).Nodes, intId) Next End Sub
|
二、增加、删除树节点
单纯在Treeview 上增加、删除、修改节点只需用Nodes属性的Add、 Remove、等方法即可,值得注意的地方是VS.NET中Treeview的Nodes集合与VS6.0中的区别,VS6.0中的是一个大的集合,而VS.NET中的是分层的每个Node下都有Nodes属性。增加、删除、修改树节点时与VS6.0相比有很大差别,特别是删除时。
Private Sub ButAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButAdd.Click’在选定的节点下添加子节点 Dim tmpNd As New TreeNode(), NdSel As TreeNode tmpNd.ID = GetNewId() NdSel = TreeView1.GetNodeFromIndex(TreeView1.SelectedNodeIndex)’选中的节点 tmpNd.Text = "新节点" NdSel.Nodes.Add(tmpNd) Dim myRow As DataRow myRow = ds.Tables("tree").NewRow() myRow("NODE_NAME") = tmpNd.ID myRow("NODE_DESCRIPT") = "新节点" & tmpNd.ID & "_" & NdSel.ID myRow("PARENT_NAME") = NdSel.ID ds.Tables("tree").Rows.Add(myRow) End Sub Private Sub ButDele_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButDele.Click’删除选中的节点 Dim idx As String = TreeView1.SelectedNodeIndex() GetNdCol(idx).Remove(TreeView1.GetNodeFromIndex(idx)) Dim dv As New DataView(), recNo As Integer dv.Table = ds.Tables("tree") dv.RowFilter= "NODEID=" & NdId dv.Delete(0) End Sub Private Function GetNdCol(ByVal idx As String) As TreeNodeCollection ‘获得选中节点的父节点的Nodes集合 Dim cnt As Integer, i As Integer Dim tmpNds As TreeNodeCollection Dim idxs() As String idxs = Split(idx, ".") cnt = UBound(idxs) If cnt = 0 Then tmpNds = TreeView1.Nodes Else tmpNds = TreeView1.Nodes(CInt(idxs(0))).Nodes For i = 1 To cnt - 1 tmpNds = tmpNds(CInt(idxs(i))).Nodes Next End If Return tmpNds End Function
|
三、修改、移动树节点
由于服务器控件不支持鼠标拖动事件,所以不能象Windows程序那样通过拖动移动节点,这里是通过选择父节点的方式。移动是通过在原位置删除,新位置添加实现的,要注意在删除时先保存节点信息。
Private Sub TreeView1_SelectedIndexChange(ByVal sender As Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView1.SelectedIndexChange Dim dv As New DataView() dv.Table = ds.Tables("tree") Dim tmpNd As TreeNode = TreeNdSel(e.OldNode), tmpNds As TreeNodeCollection dv.RowFilter= "NODEID=" & tmpNd.ID dv(0)("NODE_DESCRIPT") = Me.TextBox1.Text dv(0)("ADDRESS") = Me.TextBox2.Text dv(0)("TARGET") = Me.TextBox3.Text dv(0)("ICON") = Me.TextBox4.Text If dv(0)("PARENTID").ToString <> Me.DropDownList1.SelectedItem.Value Then ‘移动节点 dv(0)("PARENT_NAME") = Me.DropDownList1.SelectedItem.Value If Me.DropDownList1.SelectedItem.Value = "ROOT" Then tmpNds = TreeView1.Nodes Else tmpNds = FromIdToNode(Me.DropDownList1.SelectedItem.Value, TreeView1.Nodes).Nodes’新的父节点的Nodes集合 End If GetNdCol(e.OldNode).Remove(tmpNd) tmpNds.Add(tmpNd) End If tmpNd.Text = Me.TextBox1.Text tmpNd.ImageUrl = Me.TextBox4.Text tmpNd = TreeView1.GetNodeFromIndex(TreeView1.SelectedNodeIndex) dv.RowFilter= "NODEID=" & tmpNd.ID Me.TextBox1.Text = dv(0)("NODENAME").ToString Me.TextBox2.Text = dv(0)("ADDRESS").ToString Me.TextBox3.Text = dv(0)("TARGET").ToString Me.TextBox4.Text = dv(0)("ICON").ToString End Sub Private Function FromIdToNode(ByVal ID As String, ByVal Nds As TreeNodeCollection) As TreeNode ‘由关键字查找节点 Dim i As Integer Dim tmpNd As TreeNode, tmpNd1 As TreeNode For Each tmpNd In Nds If tmpNd.ID = ID Then Return tmpNd Exit Function End If tmpNd1 = FromIdToNode(ID, tmpNd.Nodes) If Not (tmpNd1 Is Nothing) Then Return tmpNd1 Exit Function End If Next Return Nothing End Function
|
四、结束语 以上阐述ASP.NET中树状显示的基本方法,以及如何在对树节点进行维护(增加、删除、修改、移动)的同时,修改数据库数据。由于篇幅所限,笔者在此只对基本思路和流程及关键步骤作了介绍,并未列出详细源代码,读者可自行完善。需要详细源代码者可与我联系,本文程序在VS.NET、SQLServer、Windows 2000、IIS5.0下调试通过。
标达到的效果:两个下拉框,第二个跟随第一个变化而变化,使用客户端脚本 JavaScript在ASP.NET环境下实现。
第一步:建立JavaScript脚本:
在Page_Load中建立并注册这个js脚本:
string scriptKey = "MenuChange";
if (!Page.IsStartupScriptRegistered(scriptKey) && !Page.IsPostBack)
{
string scriptBlock =
@"<script language=""JavaScript"">
<!--
function InitBigClass()
{
bigclass = new Array();
bigclass[0] = new Array();
bigclass[0][0] = '0';
bigclass[0][1] = '全部论坛';
bigclass[1] = new Array();
bigclass[1][0] = '3';
bigclass[1][1] = 'Web 开发';
bigclass[2] = new Array();
bigclass[2][0] = '4';
bigclass[2][1] = '软件工程/管理';
}
function InitSmallClass()
{
smallclass = new Array();
smallclass[0] = new Array();
smallclass[0][0] = '301';
smallclass[0][1] = 'ASP';
smallclass[0][2] = '3'; // 此处与上面的大类对应
smallclass[1] = new Array();
smallclass[1][0] = '303';
smallclass[1][1] = 'PHP';
smallclass[1][2] = '3';
smallclass[2] = new Array();
smallclass[2][0] = '401';
smallclass[2][1] = '软件工程';
smallclass[2][2] = '4';
smallclass[3] = new Array();
smallclass[3][0] = '403';
smallclass[3][1] = '软件测试';
smallclass[3][2] = '4';
}
InitBigClass();
InitSmallClass();
function changeitem(myfrm) // 主要js的函数!!!
{
var SelectedBigId,i,j;
for (i= myfrm.smallclassid.options.length-1;i>=0 ;--i)
{
myfrm.smallclassid.options[i] = null;
}
SelectedBigId = myfrm.bigclassid.options[myfrm.bigclassid.selectedIndex].value;
j = 0;
for (i=0 ;i< smallclass.length ;i++)
{
if (SelectedBigId == smallclass[i][2])
{
myfrm.smallclassid.options[j] = new Option(smallclass[i][1],smallclass[i][0]);
++j;
}
}
}
//-->
</script> ";
Page.RegisterClientScriptBlock(scriptKey, scriptBlock); // 注册这个脚本
}
第二步:在页面中加入两个<select>
<select id="bigclassid" onchange="javascript:changeitem(document.Form1);" name= "bigclassid"> (Form的id为Form1)
<option value="0" selected>全部论坛</option>
…
</select>
<select id="smallclassid" name="smallclassid">
<option>请您选择</option>
</select>
注意select的id和name属性要与上面的js相一致。
第三步:在Button_OnClick()中加入代码
int i;
for(i=0;i<Request.Form.Count;i++)
if(Request.Form.AllKeys[i].ToString()=="smallclassid")
break; // 从form中找到这个select (根据id或者name查找)
int SelectValue = Request.Form.GetValues(i)[0]; // 这个值就是select选中的值
在前面:
原文是我在需要使用进度条时找到的一篇文章,讲解详细并附有实例。我在原文的基础上加上了自己的修改:增加了线程处理并且将进度条的使用放到了子线程中处理。这是我第一次翻译文章,敬请各位指正。原文见于http://www.myblogroll.com/Articles/progressbar/,请对照参考。
谁说在WEB应用程序中不能使用进度条?我认为能。本文将介绍在服务端长时间的处理过程中通过使用进度条提高WEB应用程序的质量和界面友好度。事实上,如果一个WEB应用程序一直运行在无状态和无连接状态下,用户很容易认为事情已经结束了。但是本文介绍的不使用任何ActiveX控件和乱七八糟的Java Applets的进度条将有助于改善这点。
在一个WEB应用程序中能够使用进度条的关键是浏览器有能力在所有页面加载完之前显示页面。我们将使用这点特性来有步骤的生成并且发送页面给客户端。首先,我们将使用HTML生成一个完美并且漂亮的进度条,然后我们动态的发送Javascript块以更新进度条。当然,以上的所有内容都是在断开用户请求之前实现的。在C#中,Response.Write允许我们加入自定义内容到缓存区并且Response.Fluse()允许我们把所有缓存区中的内容发送到用户的浏览器上。
第一步:
第一步让我们来建立一个进度条页面,我们使用progressbar.aspx。如上所述,我们逐步生成并发送页面到客户端。首先,我们将使用HTML生成一个完美并且漂亮的进度条。所需要的HTML代码我们可以从事先定义的progressbar.htm中获取,所以,第一件事情是装载它并且将数据流发送到客户端的浏览器,在progressbar.aspx的Page_Load中加入如下几行:
string strFileName = Path.Combine( Server.MapPath("./include"), "progressbar.htm" );
StreamReader sr = new StreamReader( strFileName, System.Text.Encoding.Default );
string strHtml = sr.ReadToEnd();
Response.Write( strHtml );
sr.Close();
Response.Flush();
以下是progressbar.htm的HTML代码,(译注:作者把脚本函数放在了另外一个js文件中,但我嫌麻烦就也放在了这个静态页面中了)
<script language="javascript">
function setPgb(pgbID, pgbValue)
{
if ( pgbValue <= 100 )
{
if (lblObj = document.getElementById(pgbID+'_label'))
{
lblObj.innerHTML = pgbValue + '%'; // change the label value
}
if ( pgbObj = document.getElementById(pgbID) )
{
var divChild = pgbObj.children[0];
pgbObj.children[0].style.width = pgbValue + "%";
}
window.status = "数据读取" + pgbValue + "%,请稍候...";
}
if ( pgbValue == 100 )
window.status = "数据读取已经完成";
}
</script>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style/common.css" />
</head>
<body bgColor="buttonface" topmargin="0" leftmargin="0">
<table width="100%" height="100%" ID="Table1">
<tr>
<td align="center" valign="middle">
<DIV class="bi-loading-status" id="proBar" style="DISPLAY: ; LEFT: 425px; TOP: 278px">
<DIV class="text" id="pgbMain_label" align="left"></DIV>
<DIV class="progress-bar" id="pgbMain" align="left">
<DIV STYLE="WIDTH:10%"></ |