当前位置: 首页 > 图文教程 > 网络编程 > ASP > 急不可耐了?转换其他的页面吧!

ASP
asp利用dictionary创建二维数组
ASP + Serv-u 实现FTP的代码
asp获取数据库中所有表名和字段名
SITEMAP生成程序的ASP实现
通过XMLHTTP实现模板式静态页生成
实践xml缓存技术构建高性能web站点
一个简单好用的UBB编辑器(含代码)
使用ASP脚本命令重新启动服务器
技巧:用ASP在线创建Word与Excel文档
ASP.NET后台代码实现XmlHttp跨域访问
浅析 ASP.NET编程中的十大技巧
用ASP实现IE地址栏参数的判断
ASP调用SQL Server视图和存储过程
应用:用ASP实现在线文章翻译的功能
ASP实现无组件生成验证码-GIF格式
ASP实现长文章自动分页的函数代码
深入研究Application和Session对象
提高ASP的速度的方法:GetString
ASP进阶教程Ⅶ:留言簿设置密码验证
asp获取文件md5值

ASP 中的 急不可耐了?转换其他的页面吧!


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 99 ::
收藏到网摘: n/a

      
  作 者 : 雨晨
  
  
     至于剩余的页面,我们依样画葫芦,使用ASP+ DataList或是Repeater控件。这样做是必要的,因为按设计要求需要定制的数据布局,而不是一个标准的表格显示。其中有个页面,classcatalog.aspx,有一处要求勾选值,然后根据选中的值,运行两个可能输出中的一个。该页就利用了Repeater控件,因此我们显示地创建了表格的行与列,而没有让控件来完成这一切。这是在templates的内部完成的。在ASP中,看起来是这样子的:
  
     '检查是否提供优惠
  
     If rsSessions("Special") = True Then
  
     '若本课程提供优惠,则输出“Special Offer!”
  
     Response.Write "< td valign=top align=center>" & vbCrLf
  
     Response.Write "< a href=""classdetail.asp?SessionID="
  
     Response.Write rsSessions("SessionID")
  
     Response.Write """name=""Click for more detail"">"
  
     Response.Write "Special Offer!"
  
     Response.Write "< /td>"
  
     Else
  
     '若本课程不提供优惠,则在栏中输出"--"
  
     Response.Write "< td valign=top align=center>--< /td>"
  
     End If
  
     为了在ASP+中达到同样的效果,我们使用了一个函数。在脚本块中,位于Page_Load 事件下,我们创建以下代码:
  
     Function CheckSpecial(ByRef blnSpecial As Boolean, _
  
     ByRef intNumber As Integer) As String
  
     If blnSpecial = True Then
  
     CheckSpecial = "< a href=" & Chr(34) & _
  
     "classdetail.aspx?SessionID=" & _
  
     intNumber & Chr(34) & ">Special!!< /a>"
  
     Else
  
     CheckSpecial = "--"
  
     End If
  
     End Function
  
     然后只须从ASP+ Repeater中调用函数:
  
     < template name = "ItemTemplate">
  
     < tr>
  
     [ other data being displayed ]
  
     < td valign=top align=center>
  
     < %=CheckSpecial(Container.DataItem("Special"),
  
     Container.DataItem("Session_ID"))%>
  
     < /td>
  
     < /tr>
  
     < /template>
  
     Container指的是涉及我们的ASP+ Reapter控件的数据的父对象。通过调用Container.DataItem("Special")及Container.DataItem("Session_ID") ,将父对象(即ASP+ Repeater控件)中的列的值传递给了函数。