2013年10月10日 星期四

巢狀ListView後端DataBind技巧

巢狀ListView的缺點就是設計時看不到內層的長相...
一般來說巢狀ListView後端DataBind後再往下一層便無ItemDataBound事件可用了所以需要自行另寫委派。

IIS 7上出現'vfpoledb.1' 提供者並未登錄於本機電腦上。--解決了

在使用64位元windows 7的IIS時,突然原本可以用的程式出現=>'vfpoledb.1' 提供者並未登錄於本機電腦上。
找了很多資料原來VFPOLEDB不支援64位元....
後來找到一篇"開啟 IIS 7.5 中32位元程式支援 ADODB.Connection"的文章,一試果然可以了....YA...

參考網站:
http://www.eion.com.tw/Blogger/?PID=1074

頁面輸出繁簡中文轉換

心得:
利用VB的功能來做,速度比先前找的方式(比對方式)快多了。
為了偷懶結合修改了2種方式,所以CODE有點亂。....:P
有時間再試試javascript方式。

參考網頁:
http://www.dotblogs.com.tw/jeff377/archive/2008/03/17/1718.aspx

程式碼範例:

Imports System.IO

Partial Class _Default
  Inherits System.Web.UI.Page

  '''
  ''' 將繁體中文字轉換成簡體中文。
  '''
  ''' 文字內容。
  Public Shared Function Big5ToGb(ByVal Text As String) As String
    ' 將繁體中文字轉換成簡體中文,LocaleID 設為 2052
    Return StrConv(Text, VbStrConv.SimplifiedChinese, 2052)
  End Function

  '''

取得DataPager目前所在頁數的範例程式

備註:
1.DataPagerListView為ListView=>ListViewProductsList使用的DataPager。
2.HiddenFieldCurrentPageNo為存放目前所在頁數。
3.寫在ListViewProductsList的DataBound事件中。

 Private Sub ListViewProductsList_DataBound(sender As Object, e As System.EventArgs) Handles ListViewProductsList.DataBound
        '
        If Me.DataPagerListView.TotalRowCount > 0 Then
            Dim CurrentPageNo As Integer = Math.Ceiling(((Me.DataPagerListView.StartRowIndex + Me.DataPagerListView.MaximumRows) / Me.DataPagerListView.MaximumRows))
            Me.HiddenFieldCurrentPageNo.Value = CurrentPageNo.ToString
            'Me.LabelCurrentPageNo.Text = CurrentPageNo.ToString
        Else
            'Me.LabelCurrentPageNo.Text = "0"
            Me.HiddenFieldCurrentPageNo.Value = "0"
        End If

  End Sub

LinqToSql 範例

http://msdn.microsoft.com/en-us/vbasic/bb688085

ASP.Net 的 UTF-8 轉 Big5 及 Big5 轉 UTF-8

ASP.Net 的 UTF-8 轉 Big5   及  Big5 轉 UTF-8 備忘

引用於:
http://www.neo.com.tw/archives/335

http://www.dotblogs.com.tw/topcat/archive/2010/11/04/18807.aspx

利用 jQuery scrollto 移動至某元素位置 & 應用

目前我是應用在論壇移動至某樓帖子。
需先置入樓層位置的元素,在ListView中放元素HyperLink,如:
<asp:HyperLink ID="HyperLinkFloorNum" runat="server" ClientIDMode="Predictable" NavigateUrl="#">asp:HyperLink>
id的名稱: 
ContentPlaceHolder_ListViewForumPost_HyperLinkFloorNum_XX
 jQuery scrollto用法:
先引入js
<script src="js/jquery.scrollto.js"  type="text/javascript">script>
伺服端語法:
Dim Flr As Integer '接樓層資料
 ...
Dim FlrIdName As String = "ContentPlaceHolder_ListViewForumPost_HyperLinkFloorNum_" + Flr.ToString 
Page.ClientScript.RegisterStartupScript(Me.GetType, "", "$('#" + FlrIdName + "').ScrollTo();", True) 
 PS.搭配先前文章"DataPager指定跳頁功能"...可以做到直接跳到該樓層的分頁,
      'JumpPage(maxPages)
            Dim PageNo As Integer = 1
            'Try
            '    PageNo = Integer.Parse(Request("PageNo"))
            '    If PageNo <= 0 Then
            '        PageNo = 1
            '    End If
            'Catch ex As Exception
            '    PageNo = 1
            'End Try
            
            '移至樓層
            Dim Flr As Integer
            Try
                Flr = Integer.Parse(Request("Flr"))
                PageNo = Int(Flr / 10) + 1
                If PageNo > maxPages Then
                    PageNo = maxPages
                End If
            Catch ex As Exception
                Flr = 0
            End Try
            Flr = Flr - (PageNo - 1) * 10
            Try
                If Flr > 0 Then
                    '                    
                    Dim FlrTextBoxName As String = "ContentPlaceHolder_ListViewForumPost_HyperLinkFloorNum_" + Flr.ToString                    
                    Page.ClientScript.RegisterStartupScript(Me.GetType, "", "$('#" + FlrTextBoxName + "').ScrollTo();", True)
                    
                End If
            Catch ex As Exception
                '移至最下方
                Me.txtBottom.Focus()
            End Try
            ''移至最下方
            'Me.txtBottom.Focus()
            '移至第X頁
            JumpPage(PageNo)
參考:
http://flesler.blogspot.com/2008/02/jqueryserialscroll.html
http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
http://plugins.jquery.com/project/ScrollTo
DEMO參考:
http://demos.flesler.com/jquery/scrollTo/