<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      從ASP遷移至ASP+ --急不可耐了?轉換其他的頁面吧

      [摘要]急不可耐了?轉換其他的頁面吧!作 者 : 雨晨    至于剩余的頁面,我們依樣畫葫蘆,使用ASP+ DataList或是Repeater控件。這樣做是必要的,因為按設計要求需要定制的數據布局,而不是...
      急不可耐了?轉換其他的頁面吧!
      作 者 : 雨晨


         至于剩余的頁面,我們依樣畫葫蘆,使用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控件)中的列的值傳遞給了函數。





      日韩精品一区二区三区高清