是否有可能使用'使用'语句在我的aspx的看法? (ASP.NET MVC) [英] Is it possible to use the 'using' statement in my aspx views? (ASP.NET MVC)

查看:91
本文介绍了是否有可能使用'使用'语句在我的aspx的看法? (ASP.NET MVC)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能适用于非MVC了。但是,是否有可能使用'使用'语句在我的aspx看法?

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

原因是,我有页面引用的资源文件进行本地化的字符串。其中一些资源引用是相当长的 - 它真的搞乱我的code

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.

由于大部分的时间,这些资源在一个命名空间specifially的观点,我只想把使用Resources.This.that页面的顶部。我似乎不能够,但 - ?有没有办法

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?

感谢

推荐答案

你的意思是像

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

此外,在web.config文件的根目录,你可以添加:

Also, in the root 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>

这篇关于是否有可能使用'使用'语句在我的aspx的看法? (ASP.NET MVC)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆