Binding a "applicationSettings" expression to a control

  • Thread starter Thread starter Susan Harris
  • Start date Start date
S

Susan Harris

I'm using the VS2008 IDE (C#) to create settings win Web.config. For
example:

<applicationSettings>
<ManagementReports.Properties.Settings>
<setting name="Company" serializeAs="String">
<value>ACME, Inc.</value>
</setting>
</ManagementReports.Properties.Settings>
</applicationSettings>

I them wanted to use the "Expression" property of a label control to bind
the setting to the label's content. However, I keep getting an error that
the setting does not exist. I've tried referencing it with:

1) ManagementReports.Properties.Settings.Company
2) ManagementReports.Properties.Settings.Default.Company
3) Properties.Settings.Company
4) Properties.Settings.Default.Company

None of them work. I can get it working if I put the setting under
appSettings directory, but it seems crazy that the two IDE provided
approaches would be incompatible. Am I missing something?
 
Hi Susan,

I don't know if this is doable by the Expression editor, but I show an idea
how to achieve that.
Instead of the label put this into Your markup
<%= ManagementReports.Properties.Settings.Default.Company %>
(hope i guessed Your settings fullname right, anyway full name needed here,
as You would access it from code behind)
For this to work however You need to set the settings access level to
public. To do this
got to the projects properties, select the settings tab, and on the upper
right side of the form, change internal to public.

If You manage to do this via the Expression editor please let me know the
way.

Hope You find this useful.
-Zsolt
 
Back
Top