Hello,
I'd like to iterate through each Page of my ASP.NET project from
within a Custom web control and access the Page.Controls collection.
I've tried using Reflection on the web project assembly, but the
controls collection count was zero. While this method gives details
of the private controls in each page, I need access to actual
instances of the controls to interrogate their individual properties.
Next I tried from with a web custom control. Using a custom
UITypeEditor, I was able to access the page object in the EditValue
method of the type editor using the following code:
////////////////////////////////////////////////////////////////////////
System.Web.UI.Page oCurrentPage = null;
System.Collections.IEnumerator oEn;
// Use context parameter to determine page
oEn = ((System.Web.UI.WebControls.WebControl)
context.Instance).Site.Container.Components.GetEnu merator();
// Get the page that the control is situated on...
oEn.MoveNext();
oCurrentPage = (System.Web.UI.Page)oEn.Current;
////////////////////////////////////////////////////////////////////////
This was a step in the right direction, as I was able to get access to
the controls collection. The only problem is that I can't access
other pages of the same project from within this control.
The only other thing I can think of is using ENVDTE to go through the
project files, but I don't think I would have the same amount of
control and would end up having to manually parse the ASPX files,
which would be very messy.
I would be most grateful if anyone has time to help.
Many thanks,
James