提供支援自訂分頁之 ASP.NET Mobile 控制項的事件資料。
命名空間: System.Web.UI.MobileControls
組件: System.Web.Mobile (在 system.web.mobile.dll 中)
語法
'宣告
Public Class LoadItemsEventArgs
Inherits EventArgs
'用途
Dim instance As LoadItemsEventArgs
public class LoadItemsEventArgs : EventArgs
public ref class LoadItemsEventArgs : public EventArgs
public class LoadItemsEventArgs extends EventArgs
public class LoadItemsEventArgs extends EventArgs
備註
類別 (Class) LoadItemsEventArgs 物件提供事件資料,其中包含有多少項目會視需要載入控制項的相關資訊。
範例
在下列程式碼中,示範了 OnLoadItems 事件如何呼叫函式 LoadNow。ItemIndex 屬性會決定要加入至陣列 (其已繫結至清單) 的項目數。若要查看這個範例的效果,您必須在可以對清單分頁的裝置上檢視網頁。
注意事項 |
|---|
以下程式碼範例使用單一檔案程式碼模型,如果直接複製到程式碼後置 (Code-Behind) 檔案即可能無法作用。這個程式碼範例必須複製到副檔名為 .aspx 的空白文字檔。如需詳細資訊,請參閱 ASP.NET Web 網頁程式碼模型。 |
<%@ Page Language="VB"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
' Called by the List whenever it needs new items
Private Sub LoadNow(ByVal sender As Object, _
ByVal e As LoadItemsEventArgs)
Dim i, j As Integer
i = 0
j = e.ItemIndex
Dim estItemSize As Integer = 110
' Get the optimum page weight for the device
Dim wt As Integer = _
form1.Adapter.Page.Adapter.OptimumPageWeight
' Get the number of items per page
List1.ItemsPerPage = wt / estItemSize
' Clear the current items
List1.Items.Clear()
' Build a section of the array
Dim arr As New ArrayList()
For i = 1 To e.ItemCount
arr.Add(j + i)
Next
' Assign the array to the list
List1.DataSource = arr
List1.DataBind()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:form id="form1" runat="server" Paginate="true">
<mobile:List id="List1" runat="server"
ItemCount="200" onLoadItems="LoadNow"
ItemsPerPage="8" />
</mobile:form>
</body>
</html>
<%@ Page Language="C#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
// Called by the List whenever it needs new items
private void LoadNow(object sender, LoadItemsEventArgs e)
{
int j = e.ItemIndex;
int estItemSize = 110;
// Get the optimum page weight for the device
int wt = Form1.Adapter.Page.Adapter.OptimumPageWeight;
// Get the number of items per page
List1.ItemsPerPage = wt / estItemSize;
// Clear the current items
List1.Items.Clear();
// Build a section of the array
ArrayList arr= new ArrayList();
for (int i = 1; i <= e.ItemCount; i++)
{
int v = i + j;
arr.Add((v.ToString() + " List Item"));
}
// Assign the array to the list
List1.DataSource = arr;
List1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form id="Form1" runat="server" Paginate="true">
<mobile:List id="List1" runat="server"
ItemCount="200" onLoadItems="LoadNow" />
</mobile:Form>
</body>
</html>
.NET Framework 安全性
- AspNetHostingPermission 用於裝載環境中的作業。要求值:LinkDemand,權限值:Minimal。
- AspNetHostingPermission 用於裝載環境中的作業。要求值:InheritanceDemand,權限值:Minimal。
繼承階層架構
System.Object
System.EventArgs
System.Web.UI.MobileControls.LoadItemsEventArgs
執行緒安全
這個型別的所有公用靜態成員 (即 Visual Basic 中的 Shared 成員) 都是安全執行緒。並非所有的執行個體成員均為安全執行緒。
平台
Windows 98、 Windows 2000 SP4、 Windows Millennium Edition、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
版本資訊
.NET Framework
支援版本:2.0、1.1
請參閱
參考
LoadItemsEventArgs 成員
System.Web.UI.MobileControls 命名空間
注意事項