1

I've taken over maintenance on an ASP.NET WebForms project and I'm lost as to how the previous developer implemented some of the features. Basically he has an empty Label control in a master page:

<asp:Label ID="MyLabelControl" runat="server"></asp:Label>

And this as an applicationSetting in Web.Config:

<setting name="MyLabelControl" serializeAs="String">
    <value>Test</value>
</setting>

And somehow the label is populated with the value of the application setting. I've searched everywhere and can't find where he is binding the setting's value to the label. If it was me, I would do it in the Page_Load method for the master page, but this is empty. Is there some special binding thing that I don't know about?

I've done some basic WebForms work before, but prior to this most of my ASP.NET work has been in MVC with Razor. Yes, I'm learning things backwards :). Any help you can give me in understanding how he is doing this would be great. Thanks!

jebar8
  • 2,113
  • 3
  • 21
  • 31

3 Answers3

2

You can search this code

NameValueCollection appSettings = ConfigurationManager.AppSettings;
MyLabelControl.Text = appSettings[MyLabelControl];
Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
1

If Aghilas' advice doesn't give you anything, I'd start by looking at this answer: Get value from web.config applicationSettings into ASP.NET markup

You'll probably have to do some system-wide searching, as if this site is older, it may still be using deprecated means to read the config file, as well. In that case, you might want to search for something looking like:

ConfigurationSettings.AppSettings.Get("MySetting")

And upgrade that puppy to use ConfigurationManager ASAP!

(Though, I did see an interesting article on CodeProject that warns against using that in a class ... didn't get to read it all the way through, but might be one to read as a "friendly warning" kind of thing: http://www.codeproject.com/Articles/196563/Don-t-use-ConfigurationManager)

Community
  • 1
  • 1
Jason M. Batchelor
  • 2,951
  • 16
  • 25
1

Maybe change the label's name and see what crashes? You know, introduce an error and see what pops up as no longer working...

yougotiger
  • 434
  • 4
  • 18