Hello everyone.
I have a WebForm that can be used as an UI for several aplication features. To avoid endless and confusing conditionals and others I would like to create a class using some sort of Provider Pattern, so that de Page_Load looks something like this
protected
void Page_Load(object sender, EventArgs e){
If( ! IsPostBack){
Entity entity = DataAcces.getEntity(Convert.toInt32(Session["EntityId"]));
EntityPageReader reader = GetProvider(entity);
reader.read();
}
}
Wouldn't that be nice?
The GetProvider(Entity entity) returns the correct reader based on my entity object state (ex: if it has been aproved be seccion Chief, etc) and the reader fills the information on the form.
In order to do that my reader classes need to have access to the controls from my web page.
How can I do that? A class that is in App_Code to have an atribute that is a partial class?
If my aspx file is:
Default.aspx
my codebehind
Default.aspx.cs
and my class declaration
public
partial class _Default : System.Web.UI.Page{
}
Then I would like to have something like
public abstract class EntityPageReader {
setPage(_Default default); //NOTE THAT THIS IS INCORRECT. IT'S EXACTLY WHAT I WANT TO KNOW.
}
Any ideas? Is this possible?
Thank you