Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 4th, 2004, 04:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default Dynamically created controls

Does anyone know how to keep dynamically created controls to persist between postbacks. I am able to keep their values, but if I don't recreate them each time in the code-behind they don't show up.

I am sure it is something simple, but I am unable to find it. Thanks.

J
  #2 (permalink)  
Old February 4th, 2004, 04:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
Thanks: 0
Thanked 3 Times in 3 Posts
Default

What does your Page_Load Sub look like?

  #3 (permalink)  
Old February 4th, 2004, 05:29 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Right now it consists of building the table and adding rows, labels, etc. based upon the number entered into a text box. But I have to do this on every post back. I want to do it one time and then change the values in the labels on the next post back without having to recreate them.

If I don't recreate them on postback, they don't show up. I want them act to like the controls that are designed by the form designer or is this asking too much?

J
  #4 (permalink)  
Old February 4th, 2004, 07:09 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

That's part of the problem with dynamic controls. They are truly dynamic. Unless you create them every time, they dissappear. There's no way around this aside from ensuring they are created every time.

When asp.net parses the aspx and ascx files, it instantiates all the controls it finds. So similarly, you would need to manually instantiate controls that are dynamic. Viewstate should be able to maintain their states and values and such (unless you reset those as well) but you need to make sure the control is there.

Peter
------------------------------------------------------
Work smarter, not harder.
  #5 (permalink)  
Old February 4th, 2004, 09:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

That's what I thought but I was hoping to hear otherwise. Yeah, I don't have any problem with their viewstate. Thanks for the information.

J
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help me about dynamically created controls vingo_mail ASP.NET 2.0 Basics 1 March 24th, 2008 12:54 PM
Problems with Dynamically created controls Preeti_Singh .NET Framework 1.x 1 March 7th, 2007 01:30 PM
Correctly disposing dynamically created controls simarik C# 2 December 20th, 2005 08:49 PM
Events for multiple dynamically created controls Puck312 Pro VB 6 5 August 29th, 2005 03:05 PM



All times are GMT -4. The time now is 10:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.