Registry Or Web.Config Settings

  • Thread starter Thread starter Derek Hart
  • Start date Start date
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
 
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.
 
Back
Top