2010年6月28日 星期一

ASP.net 將動態資料寫成HTML再以JS載入

前端
--------------------------------------------------------------------------------------

'原來的跑馬燈改為以JS載入



/* 以 JS 載入 跑馬燈內容 */
$('#marqueeText').load('../Marquee.html');


後端
--------------------------------------------------------------------------------------

Protected Sub FormView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdatedEventArgs)

'只要有更新過資料,就寫入新的設定檔 990617
Dim OutPutMsg As String = ""
Dim sw As New System.IO.StreamWriter(Server.MapPath("../Marquee.html"), False, System.Text.Encoding.UTF8)

'取得SQL 資料庫內容
'***************************************************************************************************************
Dim ads As New AccessDataSource("~/App_Data/AAA.mdb", "")
Dim dv As Data.DataView
Dim sb As New StringBuilder
Dim i As Integer
Dim markS As String = " "
ads.SelectCommand = " SELECT * FROM [marquee] WHERE VIS = 1 ORDER BY CTIME DESC "
dv = ads.Select(New DataSourceSelectArguments)
If dv.Count <> 0 Then
For i = 0 To dv.Count - 1
sb.Append("" & markS & markS & "" & markS & markS & dv.Item(i).Item("marqueeText") & " ")
Next
End If
sw.WriteLine(sb.ToString)
sw.Flush()
sw.Close()
sw.Dispose()

'***************************************************************************************************************

End Sub

沒有留言:

張貼留言

追蹤者