ASP出错集成处理

有的网友总是把出错页面一个一个做好后,在其它的ASP页面中调用出错的页面。比方在一个登陆页面中一般会有两个出错信息,一个是最常见的密码出错,还有一个是用户名未注册。一般的网友会做两个页面来处理,一个页面显示:出错,密码出错!,别一个面面显示:出错,用户名未注册。
其实你只要做一个页面,就可以显示不能的出错信息!

下面是程序的一个例子:

1<body><br/><br/><br/><br/><br/><br/><p> </p>
2<div align="center"><center>
3<table border="1" bordercolordark="#6699CC" bordercolorlight="#6699CC" cellspacing="0" width="400">
4<tr><td bgcolor="#C4E1FF" width="100%">出错信息</td></tr>
5<tr><td width="100%"><p align="center"><br/>   

Select case request("n")
case "1"
Response.write "用户与密码出错"
case "2"
Response.write "请填写客户名称"
End Select

1<br/><br/>
2<input name="B1" onclick="javascript:history.go(-1)" type="button" value=" 返 回 "/>
3<br/></p></td></tr>
4</table></center></div></body>

上面这个程序实例中,主要的部分是:

1Select case request("n")   
2case "1"   
3Response.write "密码出错"   
4case "2"   
5Response.write "用户名未注册"   
6End Select

您只要在判断出错的地方调用这个出错的页面(一般我会把它的文件名起为wrong.asp),在后面加上n=1,2,3......(例:密码出错时就response.redirect "wrong.asp?n=1")

这样,ASP出错的页面就集成在一个页面中处理了!我们MeetASP.net写这篇文章在于让大家都能写出简结的程序。

Published At
Categories with Web编程
Tagged with
comments powered by Disqus