M
mortb
HI all,
I'm writing a control that resides on a page which instantiates an object
from the database.
My goal is to make the control use the same object for the control as on the
page.
Something like this:
Page code behind (C#):
private void Page_Load(object sender, System.EventArgs e)
{
int objId = Request.QueryString("id");
mytype obj = getobjfromDb(objid);
MyControl theControl = new MyContro(obj);
}
Control code:
public class MyControl: WebControl, INamingContainer
{
public MyControl(mytype myObject)
{
myobj = myObject;
}
protected override void OnLoad(EventArgs e)
{
this.controls.add(new literal(myojbj.ToString());
}
private mytype myobj;
}
I find this difficult to acheive as I can't really get a grasp of the event
firing order.
* Where can I call the contructor of the control?
* How will the events find their way back to my control?
* Is the implementation of controls described in depth some where?
(Something more than
http://msdn.microsoft.com/library/d...guide/html/cpconControlExecutionLifecycle.asp)
* Is the process the page framwork goes through when processign a request
discussed somewhere?
cheers,
mortb
I'm writing a control that resides on a page which instantiates an object
from the database.
My goal is to make the control use the same object for the control as on the
page.
Something like this:
Page code behind (C#):
private void Page_Load(object sender, System.EventArgs e)
{
int objId = Request.QueryString("id");
mytype obj = getobjfromDb(objid);
MyControl theControl = new MyContro(obj);
}
Control code:
public class MyControl: WebControl, INamingContainer
{
public MyControl(mytype myObject)
{
myobj = myObject;
}
protected override void OnLoad(EventArgs e)
{
this.controls.add(new literal(myojbj.ToString());
}
private mytype myobj;
}
I find this difficult to acheive as I can't really get a grasp of the event
firing order.
* Where can I call the contructor of the control?
* How will the events find their way back to my control?
* Is the implementation of controls described in depth some where?
(Something more than
http://msdn.microsoft.com/library/d...guide/html/cpconControlExecutionLifecycle.asp)
* Is the process the page framwork goes through when processign a request
discussed somewhere?
cheers,
mortb