473,395 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ViewState don't save......

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
2 973

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: theo | last post by:
Hi... I wish to extract the text content of an Xml file and assign it to DropDownList controls at runtime.I can get the Xml file text content into the DropDownList controls (Ex...if 5 Xml text...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
6
by: John | last post by:
Hi all, I am using dynamic user controls within my web app and these controls are loaded into placeholders via the LoadControl method. My problem is this: I have usercontrolA loaded into a...
9
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
1
by: Petr SIMUNEK | last post by:
I have 3 buttons on the page. (Created dynamicaly inside For- next loop and hooked up to click event.) When different button is clicked i would like to save a different value to viewstate. In the...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
1
by: Irene | last post by:
Hello all! I'm creating a web site in ASP.NET (VB.NET). One of the requirements was to allow users to create orders going through several steps. A must have is to have an option to save the work...
2
by: Jarod | last post by:
Hey I change backColor of linkButton in my Page_Load: lbDoSth.BackColor = Color.Red; But I have multiView on this page. On one of the views I have detailsView. When I add a new row a set...
0
by: nithagowda | last post by:
Hello, I have a DropDownList for source type and a panel for displaying TreeView based on the source type.. The problem is- if i select different source type drom ddlSrcType, other than the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.