O
Ohad Ezer
Hi
I'm wondering if someone can help me with this.
I have code that dynamcally loads a control (via LoadControl). When
the code is run on the Page_Load event it loads the control and
everything is fine. When I try to run the same code on the Page's
Pre_Render, the control loads up, but the buttons inside it don't do
anything on the first click. After the first click, the page posts
back and then the loaded control works fine.
It seems like loading a control on Pre Render misses something (maybe
to do with ViewState? )
1. ANy ideas how to solve this (I need to load the control on Pre
Render) ?
2. Does anyone know what the loaded control misses between Page Load
and Pre Render?
Please see code example below.
Thank you
Ohad Ezer
This code DOESN'T WORK
private void MyFrom_PreRender(object sender, System.EventArgs e)
{
MyPlaceHolder.Controls.Add(LoadControl("MyControl.ascx"))
}
----------------------------------------->
This code WORKS
private void Page_Load(object sender, System.EventArgs e)
{
MyPlaceHolder.Controls.Add(LoadControl("MyControl.ascx"))
}
I'm wondering if someone can help me with this.
I have code that dynamcally loads a control (via LoadControl). When
the code is run on the Page_Load event it loads the control and
everything is fine. When I try to run the same code on the Page's
Pre_Render, the control loads up, but the buttons inside it don't do
anything on the first click. After the first click, the page posts
back and then the loaded control works fine.
It seems like loading a control on Pre Render misses something (maybe
to do with ViewState? )
1. ANy ideas how to solve this (I need to load the control on Pre
Render) ?
2. Does anyone know what the loaded control misses between Page Load
and Pre Render?
Please see code example below.
Thank you
Ohad Ezer
This code DOESN'T WORK
private void MyFrom_PreRender(object sender, System.EventArgs e)
{
MyPlaceHolder.Controls.Add(LoadControl("MyControl.ascx"))
}
----------------------------------------->
This code WORKS
private void Page_Load(object sender, System.EventArgs e)
{
MyPlaceHolder.Controls.Add(LoadControl("MyControl.ascx"))
}