I have created a control on my Site.Master page which pulls data from an external XML file to generate additional page content. This control relies on knowing which content page was loaded in order to select the correct content from the XML file. The control’s methods are launched from the Page_Load event handler in Site.Master.
The problem I’m having is that I don’t know how to determine (from the Site.Master page) which content page was loaded. I have tried using hidden fields on each content page, but because they have the same it causes conflicts in _Default. I could give them different names, but right now I can’t see a way to handle that without some ugly looking logic blocks. If I can’t find a good solution for this (which I’m sure must exist), I’ll have to settle for calling the control from every content page’s Page_Load handler. I suppose that’s not a terrible solution, but I’m trying to avoid code duplication if at all possible.
You can always get a reference to the current page(even in a static context) via
HttpContext: