Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Namespace

What is the namespace the Default.aspx page resides in when I create an ASP.NET project?

And how to find the namespace of any other ASP.NET page in the project?

I am using VS2005. I first created a blank solution and then added a webSite to it.

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.

I am using C# and VS2005. This will not match VS2008 in this case.

like image 484
user366312 Avatar asked Aug 09 '09 15:08

user366312


People also ask

What is namespace in asp net C#?

The namespace keyword is used to declare a scope that contains a set of related objects. You can use a namespace to organize code elements and to create globally unique types.

What is namespace example?

In an operating system, an example of namespace is a directory. Each name in a directory uniquely identifies one file or subdirectory. As a rule, names in a namespace cannot have more than one meaning; that is, different meanings cannot share the same name in the same namespace.

Does C# need a namespace?

They're used especially to provide the C# compiler a context for all the named information in your program, such as variable names. Without namespaces, for example, you wouldn't be able to make a class named Console, as . NET already uses one in its System namespace.


1 Answers

Web Sites do not have/support namespace. Web Applications do.

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).

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.

like image 190
o.k.w Avatar answered Oct 13 '22 13:10

o.k.w