LoadViewState override not firing in UserControl

U

Umbaga

We're trying to get an override void LoadViewState to fire in a user
control that has been added dynamically to the page. The SaveViewState
seems to be firing just fine as evidenced by the
System.Diagnostics.Debug inserted into the overrides.

In a nutshell, the page loads a control in response to a button click.
The page then loads a Control that contains HTML to give the Final
Control A border. Then this newly loaded control loads a control
determined by the button clicked on the page.

The page's LoadViewState override fires just fine. But once the first
user control attempts to load the viewstate, it fails.

Thanks
 
L

Lostinet.Web Support

how do you load you usercontrol dynamically?

--
http://www.lostinet.com/
Lostinet.Web Controls&Components help you to build better Asp.Net
CustomerControl&UserControl&Application.
ControlHelper&HelperElement for MessageBox&Dialog
ComboBox,ComboCalendar,SmartIframe
 
U

Umbaga

There's a number of levels to this process. We're not that good at the
technical jargon.

The main page is Index.aspx
In the code-behind Index.aspx.cs file the html elements are
constructed and added to the page.

A custom-control: ElementManager which extend INamingcontainer and
System.Web.UI.WebControls.WebControl is also added to the Index page
programatically.

The ElementManager is being declared as a member of the class(inside
the "public class Index" but outside of "private void Page_Load")

In Page_Load the the HTML is built and added with "this.controls.add"
and the ElementManager is added to an HtmlGenericControl("Form").

Other Controls are added to the ElementManager in CreateChildControls,
but the ElementManager is the first layer at which the override of
LoadViewState does not function.

Any suggestions will be most appreciated.
This is the class for the Index

public class Index : System.Web.UI.Page
{
private System.Web.UI.HtmlControls.HtmlGenericControl HTML;
public System.Web.UI.HtmlControls.HtmlGenericControl HEAD;
public System.Web.UI.HtmlControls.HtmlGenericControl TITLE;
public System.Web.UI.HtmlControls.HtmlGenericControl BODY;
private System.Web.UI.HtmlControls.HtmlForm FORM;
public System.Web.UI.WebControls.OurControls.ElementManager
ElementMGR;

private void Page_Load(object sender, System.EventArgs e)
{
HTML = new HtmlGenericControl("HTML");
this.Controls.Add(HTML);
HEAD = new HtmlGenericControl("HEAD");
HTML.Controls.Add(HEAD);
TITLE = new HtmlGenericControl("TITLE");
HEAD.Controls.Add(TITLE);
BODY = new HtmlGenericControl("BODY");
FORM = new HtmlForm();
ElementMGR = new System.Web.UI.WebControls.OurControls.ElementManager();
this.FORM.Controls.Add(ElementMGR);
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top