Hi all
I found this extremely useful article on creating instances of ASP.NET UserControls in .ASHX Handlers by Scott Guthrie.
Unfortunately I now have a requirement now where I need to create an instance of a UserControl which has a dependency on the parent page. This being the case, I can't use the same method to create the UserControl.
Can anyone suggest how I might go about this? What is involved in creating an instance of the Parent page and then getting the contents of the UserControl it contains?
Just for reference & to be specific on the type of depenendency I'm dealing with, the UserControl is a panel that exists on a main Factsheet page. Depending on the user's configuration preferences, different controls are dynamically generated in the Factsheet's base class FactsheetBuilderPage, and included on the page.
The UserControl has properties, such as:
public DateTime EffectiveDate
{
get
{
return ((FactsheetBuilderPage)this.Page).EffectiveDate;
}
}
public Site ConfiguredSite
{
get { return ((FactsheetBuilderPage)this.Page).SiteConfiguration; }
}
public ConfiguredFund Fund
{
get
{
return ((FactsheetBuilderPage)this.Page).Fund;
}
}
which reference the FactsheetBuilderPage class, which means I need to create a FactsheetBuilderPage class for it to reference.
Ideally I'd be able to resolve this issue without having to modify the existing code base, because refactoring this will be a real pain!!
Thanks guys
Dave