Binding a "applicationSettings" expression to a control

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?
 
M

miher

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top