日期:2010-12-16 浏览次数:20943 次
'检查是否提供优惠 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控件)中的列的值传递给了函数。 |