Feb 19, 2008

Accessing Web.Config AppSettings Collection Value

Web.config Settings:

** replace ( to < ** replace ) to >

(appSettings)
(add key="ContentFrameHeight" value ="600px"/)
(add key="ContentFrameWidth" value="700px"/)
(add key="MenuFrameHeight" value="400px"/)
(add key="MenuFrameWidth" value="250px" /)
(/appSettings)


Usually AppSettings placement:
configuration
configSections
"AppSettings"
system.web


Before using System.Configuration.Manager
We might need to add .NET reference, because by default this reference might not be added.
1. Right click "Add reference" > Add the System.Configuration as below figure.



Then you can apply the syntax below:


E.g syntax:
Dim height As String = ConfigurationManager.AppSettings("ContentFrameHeight").ToString

No comments:

Post a Comment