I have a stylesheet using a for each loop over the XML doc but when it comes accross using the document() method it fails.
<td >
<xsl:value-of select="document('Departments.xml')/Departments/Department[#Id=dep]/Name"/>
</td>
The variable has a value each loop which prints out
Execution of the "document()" function was prohibited. Use the
"XsltSettings.EnableDocumentFunction" property to enable it.
I think if XslCompiledTransform is used by the asp:xml control instead of XslTransform it means that the environment you are working in has set aspnet:RestrictXmlControls to true (https://learn.microsoft.com/en-us/previous-versions/aspnet/hh975440(v=vs.120))
<appSettings>
<add key="aspnet:RestrictXmlControls" value="true" />
</appSettings>
so you might need to try/check whether your locale web.config can set it back to
<appSettings>
<add key="aspnet:RestrictXmlControls" value="false" />
</appSettings>
to have XslTransform being used where you are not restricted by default XsltSettings.
Related
There are several answered questions detailing how to refer to a single value from web.config file. I'd like to maintain lists of values with which to populate combo boxes in the Views. Should I use some sort of key/value pair structure, with the key identifying the particular combo box to populate?
<add key="CalculationMethod" value="Fixed"/>
<add key="CalculationMethod" value="Cost Plus"/>
<add key="CalculationMethod" value="Formula"/>
I'm not sure how I'd read this, or if that would even work (don't keys have to be unique?). The IntelliSense for web.config doesn't seem to allow much in the appSettings section that looks applicable to a more robust structure like
<list name="CalculationMethod">
<item value="Fixed"/>
<item value="Cost Plus"/>
<item value="Formula"/>
</list>
I see that the root <configuration> has a lot of options for children, but which one to use, if any?
You really should be using a database for something like this but if you must put it in the web.config then you could delimit the values and parse them out at run time.
<add key="CalculationMethod" value="Fixed,Cost Plus,Formula"/>
myComboBox.DataSource = new List<String>(lstrCalcMethodsFromWebConfig.Split(','));
This is strange. I thought I would easily find this information googling, but I haven't had much success. All I want to know is what are the valid characters that can be used for the keys in the AppSettings section of a Web.config file. Eg:
<add key="MySpeed" value="100" />
<add key="My.Speed" value="100" />
<add key="My Speed" value="100" />
<add key="Vélocité" value="100" />
Would all of the above keys be permitted?
The Microsoft documentation states only that the key is a String attribute. Nothing more. Their examples do show a key with spaces in the name.
I tried to add this value but it is giving me the error
<add key="RssFeedURL" value="http://www.example.com/?cat=11&feed=rss2"/>
You could encode it:
<add key="RssFeedURL" value="http://www.example.com/?cat=11&feed=rss2"/>
I have follwing in app.config file:
<appSettings>
<add key="Name" value="Office"/>
...
<add key="Name" value="HotSpot"/>
...
<add key="Name" value="Home"/>
</appSettings>
I tried
ConfigurationManager.AppSettings["Name"]
But it only gives me one Value? How can i get list of all values? I am using c# 3.5. Is there lambda expression or something i can use to get that?
You can only use one key per value, so this approach will not work.
There are two alternate approaches I can think of:
Use a single key with a delimiter, and retrieve with ConfigurationManager.AppSettings["Name"].Split(new [] { "," });.
<add key="Name" value="Office,Hotspot,Home" />
Use a custom section to create a section that can contain your array of strings.
I have the following appSettings section
<appSettings>
<add key="Foo" value="http://foo.bar.com/?app=xxx&FormName=yyy" />
</appSettings>
But the IDE is giving me two errors:
Error 25 Entity 'FormName' not defined.
Error 26 Expecting ';'.
It seems the & is causing a problem. I'd like to not have to splt the values up into seperate keys. Is there an elegant way around this issue?
You just need to use XML encoding here I believe - so & becomes &
Try &
<appSettings>
<add key="Foo" value="http://foo.bar.com/?app=xxx&FormName=yyy" />
</appSettings>