Link to home
Create AccountLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

How do I inherit from Site.Master?

I have a public property defined in Site.Master.cs, and I have defined that page as the Master Page in the Edit.aspx page. How can I access that property from Edit.aspx.cs?

Thanks,
newbieweb
Avatar of curiouswebster
curiouswebster
Flag of United States of America image

ASKER

I guess I need to make the object inherit from Site, instead of System.Web.UI.Page: pretty obvious.

But please confirm this is okay. I see that I need to then add a property to get it to compile...
When I change the inheritance, something strange happens:

When I change this:
public partial class Edit : System.Web.UI.Page

to this:
public partial class Edit : Site

I get a compilation problem since the compiler can not find the Title property

Title = table.DisplayName;

But Site inherits from System.Web.UI.Page so I do not understand why it suddenly can not find that property.  Any ideas?

newbieweb

SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
That makes sense. BUT, Title is a Public property.

An object that inherits from Site should also have access to Title.  That's classic OOP, I thought...
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I found the problem. While making a list of source code for you, I realized Site is a MasterPage, yet Edit was a Page.

I think I need to leave Site.Master.cs alone and add a new abstract Page that deals with permissions.

I see tgerbert's answer should have tipped me off that you can only reference the Master page's properties.