





















Object tags enable page developers to declare and create instances of variables using a declarative, tag-based syntax. The following example demonstrates how the object tag can be used to create an instance of an ArrayList class.
<object id="items" class="System.Collections.ArrayList" runat="server"/>
The object will be created automatically at run time and can then be accessed through the ID "items".
<html> <script language="C#" runat=server> void Page_Load(Object sender, EventArgs e) { ArrayItems.Add("One"); ArrayItems.Add("Two"); ArrayItems.Add("Three"); MyList.DataSource = ArrayItems; MyList.DataBind(); } </script> <body> <object id="ArrayItems" class="System.Collections.ArrayList" runat=server/> <asp:datalist id="MyList" runat=server> <ItemTemplate> Here is a value: <%# Container.DataItem %> </ItemTemplate> </asp:datalist> </body> </html>
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。