目前我是應用在論壇移動至某樓帖子。
需先置入樓層位置的元素,在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/
沒有留言:
張貼留言