ASP.NET Namespace(ASP.NET 命名空间)
问题描述
当我创建 ASP.NET 项目时,Default.aspx 页面所在的命名空间是什么?
What is the namespace the Default.aspx page resides in when I create an ASP.NET project?
以及如何找到项目中任何其他 ASP.NET 页面的命名空间?
And how to find the namespace of any other ASP.NET page in the project?
我正在使用 VS2005.我首先创建了一个空白解决方案,然后向其中添加了一个网站.
I am using VS2005. I first created a blank solution and then added a webSite to it.
当我单击右键并转到添加新网站"菜单时,我找到了以下模板 ASP.NEt WebSites(第一个模板),然后我将其添加到我的 sln.
When I click right-button and go to 'Add New Web Site' - menu I find the following template ASP.NEt WebSites(1st template), then I added this to my sln.
我正在使用 C# 和 VS2005.在这种情况下,这将与 VS2008 不匹配.
I am using C# and VS2005. This will not match VS2008 in this case.
推荐答案
网站没有/不支持命名空间.Web 应用程序可以.
Web Sites do not have/support namespace. Web Applications do.
要回答这个问题,由于创建了一个新的网站",因此名称空间不会发挥作用.至于如何从 Webform 页面访问其他 WebForm 页面类,我还没有找到原因.而且我不认为这是可行的(如果我错了,请纠正我).
To answer the question, since a new 'Web Site' is created, namespace doesn't come into play. As to how to access other WebForm page classes from a Webform page, I haven't figure a reason for that. And I do not think it is do-able (correct me if I'm wrong).
总之有办法解决.如果您在 Web 表单的一类中使用了一些可重用的业务/UI/其他逻辑,只需将这些方法移出到 App_Code 下的 XXX.cs 文件中.不需要命名空间,您可以在所有 webform 类中使用它.
Anyway there are ways to get around. If you have some reuable business/UI/other logics used within a class of one the webforms, simply move those methods out to say XXX.cs file under App_Code. There is no need for namespace and you can use it within all the webform classes.
这篇关于ASP.NET 命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ASP.NET 命名空间


基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01