新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > Web开发 > Asp教程 > 正文:从ASP迁移至ASP+ --转换其他的页面

从ASP迁移至ASP+ --转换其他的页面

新客网 XKER.COM 2007-01-06 来源: 收藏本文
至于剩余的页面,我们依样画葫芦,使用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控件)中的列的值传递给了函数。

收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐