Project organization question

Last post 06-13-2008 5:46 AM by Thomas Sun – MSFT. 1 replies.

Sort Posts:

  • Project organization question

    06-11-2008, 3:25 PM
    • Loading...
    • KevinAMac
    • Joined on 02-20-2008, 2:08 PM
    • Posts 115

    Hi gang,

    I know this is a dumb question but I haven't found an article online that describes how to do this --- suppose I have a Web Application Project (no App_Code folder!) with a default NameSpace of "TestApp". I have some classes that I want to be able to use from anywhere in my project. Let's say I add a new class file to the project, call it "test.cs". As I understand it:

    - I can code as many classes in this physical file and they all would be automatically accessible from the code-behind code in my web pages.
    - The names of my Classes have nothing to do with the name of physical file in which they reside (i.e. I don't have to have a Class called "Test". I could have three classes in the "test.cs" file called "Class1", Class2", and "Class3".

    If the above is true, what happens if I want to put this class file ("test.cs") in a subfolder called "Classes?" It appears that the contents are no longer visible to the other project files. What is the right way to put common classes in a subfolder off the main project root folder and then be able to reference those classes from the code in the rest of my project?

    As a related question, if I end up creating a bigger project where I want to group my forms into main categories (e.g. Products, Inventory, Sales, etc.) how do I do this so that these forms are visible to the rest of the project?

    Thanks in advance,
    Kevin

  • Re: Project organization question

    06-13-2008, 5:46 AM
    Answer

    Hi,

    You can add Class file in any folder (Except App_Code folder, etc) under your ASP.NET web application.

    To make these Classes is available in page, please make sure they have the same Namespace in your project.

    If these Classes doesn't have the same Namespace with your codebehind class, you need to use Using statement to reference these Classes or use full Namespace to access them.

     

    I hope this helps.

     

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter