ASP.NET 命名空间 [英] ASP.NET Namespace

查看:13
本文介绍了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 命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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