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.W ebControls;
using System.Componen tModel;
namespace ViewStateTestCo ntrol
{
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:WebCustomCon trol1
runat=server></{0}:WebCustomCo ntrol1>")]
public class WebCustomContro l1 :
System.Web.UI.W ebControls.WebC ontrol, INamingContaine r
{
public WebCustomContro l1()
{
this.EnableView State = true;
}
protected override void Render(HtmlText Writer output)
{
if (!Page.IsPostBa ck) ViewState["a"] = "a";
output.Write(Vi ewState["a"].ToString());
}
}
}
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.W ebControls;
using System.Componen tModel;
namespace ViewStateTestCo ntrol
{
[DefaultProperty ("Text"),
ToolboxData("<{ 0}:WebCustomCon trol1
runat=server></{0}:WebCustomCo ntrol1>")]
public class WebCustomContro l1 :
System.Web.UI.W ebControls.WebC ontrol, INamingContaine r
{
public WebCustomContro l1()
{
this.EnableView State = true;
}
protected override void Render(HtmlText Writer output)
{
if (!Page.IsPostBa ck) ViewState["a"] = "a";
output.Write(Vi ewState["a"].ToString());
}
}
}