I am able to access the value of a property defined in the Settings.settings file in my class file SomeClass.cs as such:
TestProject.Properties.Settings property = Properties.Settings.Default;
string myValue = property.someValue;
However, I would like to access property values from my Default.aspx page. I have tried:
<%
TestProject.Properties.Settings property = Properties.Settings.Default;
%>
It gives an error on the right side for Properties saying: "The name properties does not exist in the current context."
Is it possible to access property items from an .aspx file? The only alternative I can think of is to create a .cs class that just reads property items and provides getters the .aspx file could use.
Thats because
Settings
class is defined asinternal
. You can workaround that with something like this on your code-behind:...
...
...
And back in your aspx:
But I suggest you to use
web.config
to store settings stuff.I ended up just making a class specifically for retrieving those property values:
Example:
Then in the .aspx file I retrieve the values as such:
If anyone knows of an easier way to do this I'd like to get some comments on it.