views:

292

answers:

2
+6  A: 

Namespace must be declared/imported somewhere. You can do that either:

  • within the page itself
  • master page or
  • inside web.config file

If you want something global it's best to configure your namespace in web.config.

Use <@import...> directive for the first two and <namespace> configuration element for the last one.

Robert Koritnik
Thanks all! I didn't consider the web.config earlier...Thanks!
josecortesp
an up vote would help... :)
Robert Koritnik
BTW: You also gain points for yourself if you accept any of the answers, that solved your problem.
Robert Koritnik
+2  A: 

You can add the namespace to the web.config and then you won't have to worry about it later.

Inside your web.config, you should see something like this:

<namespaces>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Linq"/>
<add namespace="System.Collections.Generic"/>
</namespaces>

Just add a line with your namespace.

If you don't want the helpers to be globally imported, each directory can have it's own web.config. Unless specifically set, those "sub" web.configs will inherit settings from higher web.configs. If you go this route, be forewarned, some settings can only be set at the application level. It can get confusing fast.

Jere.Jones