Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Retrieve AppSettings in HTML

$
0
0

The section in web.config in which you are setting this is for setting environment variables and not strings.

You should add an appsettings section under the configuration header and read the value from there:

<appsettings>
    <add value="KeyValue" key="KeyName"></add>
  </appsettings>

and then you can set this either within the html or within code-behind code:

html

<asp:LabelID="Label1"runat="server"Text="<%$ AppSettings:KeyName%>"></asp:Label>

or code behind

 

          declare config as type System.Configuration.Configuration
          set config to type WebConfigurationManager::OpenWebConfiguration("~/")
          
          if config::AppSettings::Settings::Count > 0
             set Label1::Text to config::AppSettings::Settings["KeyName"]::Value 
          else
             set Label1::Text to ""
          end-if

Viewing all articles
Browse latest Browse all 4356

Trending Articles