views:

212

answers:

1

This likely applies to non MVC too. But, Is it possible to use the 'using' statement in my aspx views?

Reason is that I have the pages reference resource files for localised strings. And some of these resource references are quite long - it's really cluttering my code.

Since most of the time these resources are in a namespace specifially for the view, I'd just like to put a 'using Resources.This.that' at the top of the page. I don't seem to be able to though - is there a way?

Thanks

+6  A: 

Do you mean like

<%@ Import namespace="MyProgram.MyNamespace" %>

Also, in the root of web.config, you can add:

<pages>
   <namespaces>
      <add namespace="System" />
      <add namespace="System.Collections" />
      <add namespace="System.Collections.Specialized" />
      <add namespace="System.Configuration" />
      <add namespace="System.Text" />
      <!-- etc -->
   </namespaces>
</pages>
Will
Yes, that's it! thanks.
UpTheCreek