Is it possible to use the 'using' statement in my aspx views? (ASP.NET MVC)

C#asp.netasp.net Mvc

C# Problem Overview


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

C# Solutions


Solution 1 - C#

Do you mean like

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

Also, inside the root <configuration> tag of web.config, you can add:

<system.web>    
    <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>
</system.web>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionUpTheCreekView Question on Stackoverflow
Solution 1 - C#user1228View Answer on Stackoverflow