Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Missing Viewstate in Custom Control

Reply
Thread Tools

Missing Viewstate in Custom Control

 
 
Mark Sisson
Guest
Posts: n/a
 
      07-18-2003
Easy one for gurus::::
Could someone tell me why this custom control bombs during postback?

To duplicate: compile this control, put it in your toolbox, drag it to
a new form, add a button to the form, run the form, hit the button.
Voila! The control doesn't remember it's ViewState.

WHY!!!!!!!!!!!!!!!!!!!!!!!!!!!!
tia


using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace ViewStateTestControl
{
[DefaultProperty("Text"),
ToolboxData("<{0}:WebCustomControl1
runat=server></{0}:WebCustomControl1>")]
public class WebCustomControl1 :
System.Web.UI.WebControls.WebControl, INamingContainer
{
public WebCustomControl1()
{
this.EnableViewState = true;
}
protected override void Render(HtmlTextWriter output)
{
if (!Page.IsPostBack) ViewState["a"] = "a";
output.Write(ViewState["a"].ToString());
}
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-databinding after user control change event - missing viewstate second time. Dave A ASP .Net 0 11-27-2007 10:58 AM
Failed to load viewstate. The control tree into which viewstate... Josema ASP .Net Building Controls 2 05-22-2005 10:38 AM
Failed to load viewstate. The control tree into which viewstate... Josema ASP .Net Web Controls 0 05-09-2005 10:58 AM
ViewState of the Composite Control composed of custom control whoisnidhee ASP .Net Web Controls 2 07-16-2004 08:05 AM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments