| sp; ConfigurationSettings.GetConfig _ ("articlesVB"), ArrayList) If Not articles Is Nothing Then For Each o In articles anArticleVB = CType(o, CustomItemHandler.Article) Response.Output.WriteLine _ (" """" & ">" & anArticleVB.Title & _ "") If Not anArticleVB.Authors Is Nothing Then s = "by " For Each obj In anArticleVB.Authors s += CType(obj, String) & ", " Next Response.Output.WriteLine _ (s.Substring(0, s.Length - 2)) End If Next End If 最后,编译并运行customItems.aspx Web窗体,可以看到尾随着一列文章信息的“ArticlesVB”标题(如图二所示),这些信息都是在Web.config文件的节中定义的。  你可以按照本文所给的步骤,为能够存储在配置文件中的任何类型的信息构建配置节处理程序。我们已经知道了如何使用内建的节来读取一般的“键/值”设置,如何使用系统定义的配置节处理程序来读取自定义节中的系统定义属性值,以及如何创建并声明自定义配置节处理程序。当希望自定义节应用于某特定服务器上的所有ASP.NET应用程序时,自定义配置节处理程序可以放在machine.config文件中,而希望自定义节只应用于一个应用程序时,则可以放在Web.config文件中。 本文作者:A. Russell Jones 文章来源:http://www.devx.com/dotnet/Article/16927/0/page/1
上一页 [1] [2] [3] [4] [5] |