Solved

Accessing appSettings syntax- Hardcoded value replaced with appSettings

Posted on 2008-06-17
6
870 Views
Last Modified: 2010-04-21
Currently I have a value that is hardcoded and I need to change it to a setting found in the web.config. I have a web.config file with a Key <add key="AVLLayer" value="AVL"/> I need to access this in the Default.aspx. See below

In web.config I have
 

<appSettings>

<add key="AVLLayer" value="AVL"/>

</appSettings>
 

in Default2.aspx I have 
 

 <esri:MapResourceItem Definition="&lt;Definition DataSourceDefinition=&quot;testweb&quot; DataSourceType=&quot;ArcGIS Server Local&quot; Identity=&quot;&quot; ResourceDefinition=&quot;(default)@AVL&quot; DataSourceShared=&quot;True&quot; /&gt;" 

                    DisplaySettings="visible=True:transparency=0:mime=True:imgFormat=PNG8:height=350:width=600:dpi=96:color=white:transbg=True:displayInToc=True:dynamicTiling=False" Name="AVL" LayerDefinitions=""/>
 
 

I need to replace the Name="AVL" with System.Configuration.ConfigurationSettings.AppSettings("AVLLayer") or something close but I can't get the syntext to work.

Open in new window

0
Comment
Question by:jtby
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 250 total points
ID: 21804727
Like this!

string s = System.Configuration.ConfigurationManager.AppSettings["AVLLayer"];
0
 

Author Comment

by:jtby
ID: 21807084
No, that does not work...I found this on the ESRI Forums in case anyone else needs it... the Solution is that you need to create you Resource Items in the code behind dyamiclly.



Subject Re: MapResourceItem Definition string  

Author George Lesser  

Date Feb 28, 2008  

Message I generally create my resources on the fly with the following code. Hope it is of some help. 
 

Private Sub SetupMapResources() 

' setup map resource service names 

Dim primarySvcName As String = ConfigurationManager.AppSettings("PrimaryServiceName") 
 

' setup primary resource 

Dim mapResource1 As New MapResourceItem 

Dim gisResourceDef As New GISResourceItemDefinition 

With gisResourceDef 

.DataSourceDefinition = "LocalHost" 

.DataSourceType = "ArcGIS Server Local" 

.Identity = "" 

.ResourceDefinition = "(default)@" & primarySvcName 

End With 

mapResource1.Definition = gisResourceDef 

mapResource1.Parent = MapResourceManager1 

mapResource1.Name = "FCWO" 

mapResource1.InitializeResource() 
 

' assign resources to map 

MapResourceManager1.ResourceItems.Add(mapResource1) 

MapResourceManager1.Refresh() 

Map1.InitializeFunctionality(mapResource1) 

End Sub 

 

Open in new window

0
 

Author Comment

by:jtby
ID: 21807127
This ended up being ESRI control issue and not asp as I origianlly thought...Thanks for the post though
0
 
LVL 16

Expert Comment

by:ororiole
ID: 21815977
Well I did answer the question and we certainly could have worked out any config errors had that been the issue. And there seems to be some useful information here from both the asker and myself that belongs in the PAQ.
0
 

Author Closing Comment

by:jtby
ID: 31468025
You can have the pts, don't matter to me.. :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now