D
DC
Hi,
I am dynamically adding a usercontrol that uses "this.IsPostBack" in
Page_Load to decide whether it must populate some of it's inner
controls or not. Since I am adding the usercontrol to the page at
runtime (on response to a click event), IsPostBack is always false and
the inner controls never get populated.
I changed "IsPostBack" to "IsInitial" now, using this property:
public bool IsInitial
{
get
{
if (ViewState["IsInitial"] == null)
{
ViewState["IsInitial"] = false;
return true;
}
return false;
}
}
I don't think this is the way to do it. If the sourcecode of the
control is not available, I cannot add the usercontrol dynamically
without running into this problem. Is there a way to explicitly set
"IsPostBack" of the control to "true" from outside somehow? I thought
using "if (!IsPostBack)" to init controls in Page_Load is recommended.
Kind regards
DC
I am dynamically adding a usercontrol that uses "this.IsPostBack" in
Page_Load to decide whether it must populate some of it's inner
controls or not. Since I am adding the usercontrol to the page at
runtime (on response to a click event), IsPostBack is always false and
the inner controls never get populated.
I changed "IsPostBack" to "IsInitial" now, using this property:
public bool IsInitial
{
get
{
if (ViewState["IsInitial"] == null)
{
ViewState["IsInitial"] = false;
return true;
}
return false;
}
}
I don't think this is the way to do it. If the sourcecode of the
control is not available, I cannot add the usercontrol dynamically
without running into this problem. Is there a way to explicitly set
"IsPostBack" of the control to "true" from outside somehow? I thought
using "if (!IsPostBack)" to init controls in Page_Load is recommended.
Kind regards
DC