tags:

views:

356

answers:

3

I have created 3 partial classes and i want all of them to be grouped under same page. Like Registration -> Registration.aspx.cs, Registration_db.cs, Registration_validation.cs.

Is it possible to group all these files under same category i.e registration under tree view of solution explorer.

<%@ Page Language="C#" MasterPageFile="~/Master Pages/LeftMenu.master" AutoEventWireup="true" CodeFile="Registration.aspx.cs,Registration_db.cs, Registration_validation.cs" Inherits="Web_Pages_Authentication_Login_Management_Registration" Title="Registration" StylesheetTheme="Default Theme 1"  %>

check codefile tag in above code. I want to do something like that

Registration.aspx.cs

public partial class Web_Pages_Authentication_Login_Management_Registration : System.Web.UI.Page
{
    private static string firstName;
    private static string lastName;
    private static string userName;
    private static string userPassword;
    private static string primaryEmail;
}

Registration_Database.cs

   public partial class Web_Pages_Authentication_Login_Management_Registration 
    {
       const string dbFirstName = "@FirstName";
       const string dbLastName = "@LastName";
       const string dbUserName= "@UserName";
       const string dbUserPassword = "@UserPassword";
       const string dbPrimaryEmail = "@PrimaryEmail";  

       void display()
          {
              firstName="XYZ"; //This variable is not accessible when i put both files in different directories
          }
    }

When both these partial classes are saved into different directories than variables declared in 1st file are not accessible by 2nd and vice versa which actually i was expecting

A: 

I'd question whether structuring your code like this is the best way anyway. Each class should have a single responsibity. Partial classes exist to extend code generated classes, not to divide different functionality into different files.

Charlie
thx anyway to object about the best way, I dont know whether it is a gud way or not. But what i feel here is that i am not forming different class for that. I m using partial class so that different users can work simultaneously
Shantanu Gupta
+1  A: 

No it's not possible, but when you have partial classes they would merged to one when both of them are in same directory/ path.

Ravia
so does it mean answer given by RickNz contradict with what u r saying, bcoz what i tried is also somewhat that u said
Shantanu Gupta
Yes it is right as per my knowledge. I don't see RickNz answer here
Ravia
A: 

I agree to Charlie queried below, you should create constant file where you keep all your constansts and have a utility class where you can have utility functions

Ravia