CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

又一个运行不了的例程,请各位帮帮忙!!

楼主marist(我想学编程)2002-04-13 03:01:13 在 Web 开发 / ASP 提问

两个asp程序,一个名为respond.asp,另一个asp7b.asp,先运行respond.asp,可ie总是说最后一行的代码出错,请各位帮忙看看。谢谢!!  
   
  respond.asp  
  **************************************************************************  
  <%  
  Dim   user  
  Dim   flag  
  Dim   pwd  
  Dim   say  
  Response.buffer   =   true   '开启缓冲页面功能  
  Response.ContentType   =   "text/html"  
  Response.Charset   =   "gb2312"  
  user   =   Request.Form("username")  
  pwd   =   Request.Form("password")  
  say   =   Request.QueryString("say")  
  %>  
  <form   method   =   "POST"   action   =   "asp7b.asp">  
  <p>用户名:<input   type   =   "text"   name   =   "username"   size   =   "12"><br>  
        口   令:   <input   type   =   "password"   name   =   "password"   size   =   "12"><br>  
        <input   type   =   "submit"   value   =   "   提交   "   name   =   "B1">  
        <input   type   =   "reset"   value   =   "   取消   "   name   =   "B2">  
  </p>  
  </form>  
  <%  
  If   say   =   1   Then  
  Response.Write"欢迎光临!"  
  End   If  
  If   say   >   1   Then  
  Response.Write"欢迎再次光临!"  
  End   If  
  If   user   =   "Jliu"   and   pwd   =   "hello"   Then  
  Response.Expires   =   1   '设置该页面在浏览器的缓冲中存储1分钟后过期。  
  flag   =   1  
  Else   If   user   =   "guest"   and   pwd   =   "guest"   Then  
  Response.Expires   =   0   '使缓存的页面立即过期。  
  Response.Clear   '清空存储在缓存中的页面  
  flag   =   2  
  Else   If   user   =   "vip"   and   pwd   =   "vip"   Then  
  Response.Write   "欢迎VIP光临Jliu   的ASP网站"  
  flag   =   3  
  Else  
  flag   =   0  
  Response.End   '立即停止脚本处理,并将缓存中的页面输出  
  End   If  
  Response.write   "<p><a   href='asp7b.asp?flag="&flag&"'>动态网页设计   Response   对象   </a></p>"   '将变量flag的值传送给asp7b.asp  
  %>  
  **************************************************************************  
   
  asp7b.asp  
  **************************************************************************  
  <%  
  Dim   say  
  say   =   Request.QueryString("flag")  
  select   case   say  
  case   "1"  
  Response.Redirect   "respond.asp?say=1"  
  case   "2"  
  Response.Redirect   "respond.asp?say=2"  
  case   "3"  
  Response.Redirect   "respond.asp?say=3"  
  case   "0"  
  Response.Redirect   "respond.asp?say=0"  
  End   Select  
  %>  
  **************************************************************************  
   
  问题点数:100、回复次数:9Top

1 楼ChinaOk(农村表哥)回复于 2002-04-13 07:39:28 得分 0

Response.Write   "欢迎VIP光临Jliu   的ASP网站"  
  flag   =   3  
  Else  
  flag   =   0  
  Response.End   '立即停止脚本处理,并将缓存中的页面输出  
  End   If  
  end   if     '加入  
  end   if     '加入  
   
  再我上面写的地方加入两个end   if   就好了  
  注意   if   then   else   end   if的配对Top

2 楼hmbory(玻璃心)回复于 2002-04-13 08:25:03 得分 30

要不你就elseif中间不要用空格分开!纯属于语法错误:)Top

3 楼tripofdream(梦之旅)回复于 2002-04-13 08:52:56 得分 0

else   if   -->ElseIFTop

4 楼zcflion(吃大白菜的鸟--菜鸟)回复于 2002-04-13 09:20:08 得分 10

else   if   -->ElseIF  
   
  是语法出错,没大问题!Top

5 楼marist(我想学编程)回复于 2002-04-13 21:51:55 得分 0

加入了两个end   if,   else   if--->elseif  
  可是ie指出第二个end   if出错,怎么办????  
  Top

6 楼simpleease(沉思)回复于 2002-04-13 22:09:33 得分 0

应该将下面语句放在程序第一行:  
  <%Response.buffer   =   true%>  
  这是asp的语法要求Top

7 楼tripofdream(梦之旅)回复于 2002-04-13 22:16:24 得分 0

不需要加end   ifTop

8 楼marist(我想学编程)回复于 2002-04-13 22:24:10 得分 0

去掉新添加的end   if,程序可以执行,但是asp7b.asp的功能无法实现。  
  书上解释该程序可以演示设置页面缓存后出现的不同效果。可是asp7b.asp显示的是空白页面。  
   
  另:为什么不用加上end   if?if和end   if不需要一一对应吗?Top

9 楼tripofdream(梦之旅)回复于 2002-04-14 10:23:14 得分 60

ElseIf的用法:  
  If   condition   Then  
        [statements]  
  [ElseIf   condition-n   Then  
        [elseifstatements]]   .   .   .  
  [Else  
        [elsestatements]]  
  End   If    
   
  运行respond.asp时,由于request.querystring("say")的值为空,所以  
  If   say   =   1   Then  
  Response.Write"欢迎光临!"  
  End   If  
  If   say   >   1   Then  
  Response.Write"欢迎再次光临!"  
  End   If  
  这两个判断的内容都不会被执行;  
  由于user和pwd没有传回值,最后一个判断将会进入这个分支:  
  Else  
  flag   =   0  
  Response.End   '立即停止脚本处理,并将缓存中的页面输出  
  则  
  Response.write   "<p><a   href='asp7b.asp?flag="&flag&"'>动态网页设计   Response   对象   </a></p>"   '将变量flag的值传送给asp7b.asp  
  这一句就不会执行.  
  从respond.asp提交到asp7b.asp时,Request.QueryString("flag")="",所以什么也不执行,就是一片空白了.Top

相关问题

  • MSDN例程运行出错,请指教
  • 系统带的HelloWorld 例程,不能正确运行。请教了。
  • 请求例程????
  • 一个Response的例程,为何运行不了?请大家来看看
  • ▁▂▄▅▆▇一段牙长的例程,就是运行不了,请大家看看
  • 一个基本的51例程,请各位帮忙分析一下!谢谢!
  • 请大家帮忙!.net的示例程序在我这里为什么不能运行?
  • 怎样使VB程序只允许运行一个例程?
  • 怎么例程运行都出错了,谁来教教我?
  • 新手问题:运行范例程序,出现http 500错误

关键词

  • 页面
  • 脚本
  • 语法
  • 执行
  • asp
  • thenresponse
  • 缓存
  • jliu
  • elseflag
  • 光临

得分解答快速导航

  • 帖主:marist
  • hmbory
  • zcflion
  • tripofdream

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo