N
Natan
Hi...
I have an User Control that is loaded with Page.LoadControl(). It works
fine, but the code in the .ascx file never runs. an example:
control.ascx
------------
void Page_Load(object sender, EventArgs e)
{
myDiv.InnerText = DateTime.Now.ToString("d");
}
<div id="myDiv" runat="server"></div>
page.aspx (code behind)
---------
void OnInit(EventArgs e)
{
Control c = LoadControl("control.ascx");
Controls.Add(c);
}
The control is added, but the Page_Load event of the user control is
never called. Is it right? Or it has some kind of "UserControl_Load"
instead of Page_Load?
Or should i propagate the event manually in my code?
Thanks!
I have an User Control that is loaded with Page.LoadControl(). It works
fine, but the code in the .ascx file never runs. an example:
control.ascx
------------
void Page_Load(object sender, EventArgs e)
{
myDiv.InnerText = DateTime.Now.ToString("d");
}
<div id="myDiv" runat="server"></div>
page.aspx (code behind)
---------
void OnInit(EventArgs e)
{
Control c = LoadControl("control.ascx");
Controls.Add(c);
}
The control is added, but the Page_Load event of the user control is
never called. Is it right? Or it has some kind of "UserControl_Load"
instead of Page_Load?
Or should i propagate the event manually in my code?
Thanks!