为什么我应该包括在每一个aspx页面的命名空间? [英] Why should i include the namespace in each aspx page?

查看:113
本文介绍了为什么我应该包括在每一个aspx页面的命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常包括我的名字空间例如

I usually include my namespaces e.g.

using myProject.Model; 

我的.cs文件
但是当我想要遍历从myProject.Model派生的对象在我的.aspx文件中我必须总是包含指令

to my .cs files but when i want to iterate an object derived from myProject.Model in my .aspx file i must always include the directive

<%@ Import Namespace="myProject.Model" %>

这是为什么?我的意思是,如果它是Default.aspx的的宣布code隐藏文件(以default.aspx.cs)我为什么要重新添加?为什么它不可?

Why is that? I mean if it is declared in code behind file (in default.aspx.cs) of default.aspx Why should i add it again? Why it is not available?

只是想知道,但我想知道这是为什么。

Just wondering but i would like to know why is that.

感谢你在前进!

推荐答案

您可以添加的命名空间元素您的web.config中指定你想自动导入的命名空间。

You can add a namespaces element to your web.config to specify namespaces that you'd like to be imported automatically.

这篇关于为什么我应该包括在每一个aspx页面的命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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