动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

 从ASP迁移至ASP+ --急不可耐了?转换其他的页面吧

作者来源: 
阅读 3479 人次 , 2000-11-14 

急不可耐了?转换其他的页面吧!
作 者 : 雨晨


   至于剩余的页面,我们依样画葫芦,使用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控件)中的列的值传递给了函数。

  

 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:从ASP迁移至ASP+ --处理会话变量(Session Variables) 
· 下一篇:从ASP迁移至ASP+ --将HTML表格转换为ASP+数据列表
· ASP.NET虚拟主机的重大安全隐患(六)
· CNET JSP BASIC:建立一个JSP网站
· asp+中的发送者是什么意思?
· ASP.NET中树形图的实现
· 如何用asp+获取post的页面的数据


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077