Reputation: 21108
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
Upvotes: 3
Views: 2282
Reputation: 9942
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
Upvotes: 0
Reputation: 9942
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.
Upvotes: 1
Reputation: 10307
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.
Upvotes: 0