You can have the page clas in each case inherit from a common base class.
Just make sure to have that class inherit from the Page class. You'll still
have to write delegate functions to the parent class, but you gain the
ability to make small changes in one form that aren't in the other form
(trust me, it will happen).
In order to decide which form to display (assuming it depends on which user)
I would use an abstract clas factory:
public class AbstractForm : Page
{
// ... various virtual code
}
public class Form1 : AbstractForm
{
// ... implementation code
}
public class Form2 : AbstractForm
{
// ... implementation code
}
public class AbstractFactory
{
private static AbstractFactory _Factory;
private static Factory
{
get
{
if (_Factory == null)
_Factory = new AbstractFactory ();
return _Factory;
}
}
public virtual AbstractForm CreateForm();
}
public class Factory1
{
public overrides AbstractForm CreateForm()
{
return new Form1();
}
}
public class Factory2
{
public overrides AbstractForm CreateForm()
{
return new Form2();
}
}
--
Jeffrey Hornby
Hornby Consulting, Inc.
"em*******@gmai l.com" wrote:
Hi all, I am looking for a way to create two different forms, with
different look and feel. However, they would both have the same set of
controls, and reference the same code behind page. I would also like
to be able to switch between which form is displayed to the user
through the C# code. Is anything like this possible? I am using
VS2005. Thanks in advance for any ideas submitted!