By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,640 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

ViewState don't save......

P: n/a
Hi to all,

i have this problem:
my sample combine 2 components,

the first one is a simple aspx page (T1.aspx) with a
Button runat server and with the next code:

private void Page_Load(object sender, System.EventArgs e)
{
C1 c = new C1();

this.FindControl("Form1").Controls.Add(c);

}

the second component is a UserControl (C1.ascx) that i create dynamiclly like that:
protected override void Render(HtmlTextWriter writer)
{
TextBox txt = new TextBox();

txt.ID="txtSelectedParams" + UniqueID ;
this.Controls.Add(txt);

base.Render(writer);
}

the problem is that after postback the value on the textbox is gone....

please help me by let me know what am i doing wrong.

lirlir
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"lirlir" <li****@walla.co.il> wrote in message news:aa*************************@posting.google.co m...
Hi to all,

i have this problem:
my sample combine 2 components,

the first one is a simple aspx page (T1.aspx) with a
Button runat server and with the next code:

private void Page_Load(object sender, System.EventArgs e)
{
C1 c = new C1();

this.FindControl("Form1").Controls.Add(c);

}

the second component is a UserControl (C1.ascx) that i create dynamiclly like that:
protected override void Render(HtmlTextWriter writer)
{
TextBox txt = new TextBox();

txt.ID="txtSelectedParams" + UniqueID ;
this.Controls.Add(txt);

base.Render(writer);
}

the problem is that after postback the value on the textbox is gone....

please help me by let me know what am i doing wrong.

lirlir


You need to add the textbox in the Page_Load event, that is where it will get it's value.

Hans Kesting
Nov 18 '05 #2

P: n/a
Hi Hans,

I changed the creation of the textbox from the Render to the PageLoad,
but than i got 2 controls on the screen.

i want to have only one control that saves its viewstate.

lirlir
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.