M
Mike J.
I've created composite custom control which dynamically creates and arranges
it's child controls based on some xml data. Beside the simple web form
controls there is an option of loading user-controls (UC) at run-time. Child
controls are created/loaded/initialized in overridden CreateChildControls
and then arranged in pages. Meaning - put in separate HtmlTables with only
active one visible (property HtmlTable.Visible =
is_this_page_the_active_one() set just before rendering).
Now, everything works fine except the UC(s). UCs are loaded and displayed
as they should be, their child-controls are "responsive" to the events, data
entered is preserved across postbacks etc.
Only after user switches to another page (UCs parent HtmlTable.Visible =
false), and then switches back to the previous one is when UC and it's child
controls loose their view state. All other "regular" controls preserve view
states across page switching.
This left me completely confused. UCs are loaded at exact time when all the
other controls are created. They clearly preserve their view state across
the postback. I made sure (through the debugger) that UCs view state is
restored after switching to another page. It only gets lost after the switch
back. There is no special initialization of UC's child controls.
I've been struggling with this for days. Can someone please shed some light
on this problem for me?
it's child controls based on some xml data. Beside the simple web form
controls there is an option of loading user-controls (UC) at run-time. Child
controls are created/loaded/initialized in overridden CreateChildControls
and then arranged in pages. Meaning - put in separate HtmlTables with only
active one visible (property HtmlTable.Visible =
is_this_page_the_active_one() set just before rendering).
Now, everything works fine except the UC(s). UCs are loaded and displayed
as they should be, their child-controls are "responsive" to the events, data
entered is preserved across postbacks etc.
Only after user switches to another page (UCs parent HtmlTable.Visible =
false), and then switches back to the previous one is when UC and it's child
controls loose their view state. All other "regular" controls preserve view
states across page switching.
This left me completely confused. UCs are loaded at exact time when all the
other controls are created. They clearly preserve their view state across
the postback. I made sure (through the debugger) that UCs view state is
restored after switching to another page. It only gets lost after the switch
back. There is no special initialization of UC's child controls.
I've been struggling with this for days. Can someone please shed some light
on this problem for me?