L
Lukasz Lacki
i want to disable ViewState in dynamicly created control (in code).
below, sample code that DOESN'T work (but should in my opinion).
placeHolder is an control created in editor and placed on form.
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder placeHolder;
private void Page_Load(object sender, System.EventArgs e)
{
placeHolder.EnableViewState = false;
TextBox tb = new TextBox();
tb.ID = "TBID";
tb.EnableViewState = false;
tb.Text = "random" + new
Random(unchecked((int)DateTime.Now.Ticks)).Next();
placeHolder.Controls.Add(tb);
Button b = new Button();
b.Text = "Reload";
placeHolder.Controls.Add(b);
}
}
i disabled viewstate in TextBox (tb.EnableViewState = false, but ASP
still restores value generated in first post.
how can i go around that mess?
i've tried to create inherited class from TextBox that overrides
LoadViewState and SaveViewState, doing nothing, but god damn asp engine,
still (how!?) restores value.
changing value (new random number) in PreRender of some event handler is
not an option for me.
please help. thx
below, sample code that DOESN'T work (but should in my opinion).
placeHolder is an control created in editor and placed on form.
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder placeHolder;
private void Page_Load(object sender, System.EventArgs e)
{
placeHolder.EnableViewState = false;
TextBox tb = new TextBox();
tb.ID = "TBID";
tb.EnableViewState = false;
tb.Text = "random" + new
Random(unchecked((int)DateTime.Now.Ticks)).Next();
placeHolder.Controls.Add(tb);
Button b = new Button();
b.Text = "Reload";
placeHolder.Controls.Add(b);
}
}
i disabled viewstate in TextBox (tb.EnableViewState = false, but ASP
still restores value generated in first post.
how can i go around that mess?
i've tried to create inherited class from TextBox that overrides
LoadViewState and SaveViewState, doing nothing, but god damn asp engine,
still (how!?) restores value.
changing value (new random number) in PreRender of some event handler is
not an option for me.
please help. thx