Registry Or Web.Config Settings

D

Derek Hart

Trying to read web.config inside a property of a usercontrol. Cannot seem to
do it. Should this be allowed? Do I need to read from a text file, or can I
use web.config? This is a winforms app, but web is mixed in a little, so I
will have a web.config file.

Imports System.Web.Configuration.WebConfigurationManager

<CategoryAttribute("Design"), _
DefaultValueAttribute(GetType(String), ""), _
DescriptionAttribute("Name of the data field."), _
Editor(GetType(MergeFieldNameBuilder),
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property DataField() As String
Get
Return
System.Web.Configuration.WebConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString
End Get
Set(ByVal value As String)
_DataField = value
End Set
End Property
 
J

Jesse Houwing

Hello Derek,
Trying to read web.config inside a property of a usercontrol. Cannot
seem to do it. Should this be allowed? Do I need to read from a text
file, or can I use web.config? This is a winforms app, but web is
mixed in a little, so I will have a web.config file.

Imports System.Web.Configuration.WebConfigurationManager

<CategoryAttribute("Design"), _
DefaultValueAttribute(GetType(String), ""), _
DescriptionAttribute("Name of the data field."), _
Editor(GetType(MergeFieldNameBuilder),
GetType(System.Drawing.Design.UITypeEditor))> _
Public Property DataField() As String
Get
Return
System.Web.Configuration.WebConfigurationManager.ConnectionStrings("My
ConnectionString").ConnectionString
End Get
Set(ByVal value As String)
_DataField = value
End Set
End Property

For the Windows application, add the config items to the app.config and use
the normal ConfigurationManager to read the settings.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top