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

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

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

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

      一個技巧完善的專欄管理的程序->這是asp.net的第二個應用(二)

      [摘要]http://www.asp888.net 豆腐技術站 我們在上篇文章中,引用了一個函數包文件func.aspx,在這篇文章中,我們詳細講解一下,這個func.aspx 文件<%@ Assem...
      http://www.asp888.net 豆腐技術站

      我們在上篇文章中,引用了一個函數包文件func.aspx,在這篇文章中,我們詳細講解一下,這個func.aspx 文件
      <%@ Assembly Name="System.Net" %>
      <%@ Import Namespace="System.Net" %>
      <%@ Import Namespace="System.IO" %>
      <%@ Import Namespace="System.Data" %>
      <%@ Import Namespace="System.Data.SQL" %>
      '這些import 我就不說了,在前面的的文章 sp+中常用的NameSpace的講解都已經有所涉及
      <script language="VB" runat=server>
      function replaceSql(str1 as string) as string
      '在asp.net 中使用SQL 語句也會出現"'"號的問題,因此使用replace函數將"'" 轉換成 "''"
      replaceSql=replace(str1,"'","''")
      end function
      function GetConn() as SQLConnection
      '我們在這里 將連接數據庫的代碼進行統一化管理
      Dim conn As SQLConnection
      Dim Cfg as HashTable
      Cfg = Context.GetConfig("appsettings")
      Conn = New SQLConnection(cfg("Conn"))
      GetConn=Conn
      end function

      sub WritePage(start as integer,file as string,intLen as integer,intPageCount as integer,intRecCount as integer)
      '這個是一個 可移植 的 分頁的程序
      '進行分頁處理
      dim strWrite as string
      strWrite="<table border=1 width=100%><tr><td>"
      response.write(strWrite)

      if start=0 then
      strWrite="首頁"
      else
      strWrite="<a href='" & file & "?start=0'>首頁</a>"
      end if
      response.write(strWrite)

      if start>=1 then
      strWrite="<a href='" & file & "?start=" & cStr(start-intLen) & "'>上頁</a>"
      else
      strWrite="上頁"
      end if
      response.write(strWrite)

      if start+intLen<intRecCount then
      '還沒有到最后一頁數據
      strWrite="<a href='" & file & "?start=" & cStr(start+intLen) & "'>下頁</a>"
      else
      strWrite="下頁"
      end if
      response.write(strWrite)

      if start+intLen<intRecCount then
      '還沒有到最后一頁數據
      strWrite="<a href='" & file & "?start=" & cStr((intPageCount-1)*intLen) & "'>末頁</a>"
      else
      strWrite="末頁"
      end if
      response.write(strWrite & "</td><td>")

      strWrite="當前共有文章" & Cstr(intRecCount) & "篇,現在是第<font color=red>" & cStr((Start/intLen)+1) & "/" & cstr(intPageCount) & "</font>頁"
      response.write(strWrite)
      strWrite="</td></tr></table>"
      response.write(strWrite)
      end sub
      </script>
      大家在asp.net 中一定要注意,我們在asp.net 中定義函數的時候,一定要注意必須在<script runat=server ..>中
      對函數進行定義,而不能和asp一樣在 <%和%>之間定義,這樣做的好處是 對函數定義簡單明了,程序的可讀性
      提高了很多,但是有一個很不方便的地方就是 在<script>..中不能象在<%%> 中那樣方便的嵌套調用HTML
      代碼,而必須使用Response.Write(ss),這個是一個不方便的地方





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