Search code examples
asp.netcode-behindpage-lifecycle

Access asp.net page from a code behind class


This is for academic purposes, please no responses of "why would you want to do that"

If I have a page called Home.aspx and it has a code behind Home.aspx.cs.

In Home.aspx.cs I have some public properties, e.g.

public string Name { get; set; }

I have another page called Error.aspx

Can I create an instance of Home.aspx.cs from within Error.aspx.cs and access the Name property? And if not, why not.


Solution

  • Can I create an instance of Home.aspx.cs from within Error.aspx.cs and access the Name property? And if not, why not.

    Yes, you can...