Reputation: 3728
I have constants in my cs file Constants.cs. In the asp.net mvc controllers I use the constants like this ViewData[Constants.Whatever] = ...;
How can I use the constants in my aspx file? When I try to use it I get an error saying:
CS0103: The name 'Constants' does not exist in the current context
Upvotes: 1
Views: 947
Reputation: 18985
What namespace is your Constants
class is in? You have to import it; say it's Foo.App.Constants
(i.e. namespace Foo.App
), you'll want to add
<%@ Import Namespace="Foo.App" %>
to the top of your aspx file.
Upvotes: 0
Reputation: 102398
Something like this should work:
<%@ Import Namespace="System.Collections.Generic" %>
Change System.Collections.Generic with the namespace where you declare your Contants.cs code file so that it gets into the scope.
Upvotes: 0
Reputation: 176
Add the namespace of class on the web.config so it can recognize it ... probably
Upvotes: 5