简体   繁体   中英

ASP.NET Inheritance

I have 2 projects that are asp.net 2008 websites.

The file structure is as so:

P_Project
P_Project/index.aspx.cs
P_Project/App_Code/PageBase.cs

P_Project/Q_Project/App_Code/PageBase.cs

In my index.aspx page, I call P_Project's PageBase.isPLoggedIn() but how do I get access to Q_Project's PageBase.isQLoggedIn() from my index.aspx.cs page?

If they are separate web projects, you won't be able to do it unless you have a reference to the Q_Project in the P_Project (and vise versa)

This is probably a bad idea.

Instead, you should have a class library (maybe one for each of P_Project and Q_Project) and refer to each of them in your web project.

You would then be able to refer to it via Q_Project.PageBase.isQLoggedIn().

1- Did you referenced Q_Project to P_Project? If not add Q_Project to P_Project as reference.

2- Make sure PageBase.isQLoggedIn() is a public method.

3- If you don't create an instance of PageBase class then make sure PageBase.isQLoggedIn() is public and static method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM