tags:

views:

36

answers:

3

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

+3  A: 

Add the namespace of class on the web.config so it can recognize it ... probably

Edgar Zavala
A: 

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.

Leniel Macaferi
A: 

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.

kevingessner