Microsoft's explanation of the ASP.NET lifecycle page says that dynamically created controls must be created in PreInit .
It worked for me. Here is my main page:
protected global::System.Web.UI.HtmlControls.HtmlGenericControl FiltersZone;
(...)
protected override void OnPreInit(EventArgs e) { base.OnPreInit(e); FiltersZone.Controls.Add(new PlanningFiltersSurgeonWeb()); }
This dynamically created ".ascx" control contains a hidden field:
<input id="hidTxtPaint" type="hidden" name="hidTxtPaint" runat="server" />
Now I can get its value from the dynamically generated ASCX control Page_Load
event after " submit
" or " __dopostback('hidTxtPaint')
" triggered using JavaScript.
On the other hand, the value of the hidden field is always empty after POST if its main ".ascx" control is added to the main Page_Load
page.
source share