473,698 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Confusion Over Postback, ViewState and Dynamically Added Controls

Hi there:

I've checked the forums, but haven't found a situation addressing my
specific problem. Here's the deal:

I've got a Web Form containing two Panel controls. One displays search
results in a DataList comprised mainly of LinkButtons. The other's basically
empty; it's intended to handle a collection of dynamically added controls.

When the user clicks a LinkButton from within the first Panel control, I
want to be able to take the argument passed by that click and add, to the
second Panel control, an IFRAME tag with a reference to load from a URL based
on what the user clicked. This panel should be able to contain one 'n'
IFRAME tags.

The problem I'm having is that with each PostBack, the Panel that's supposed
to contain the "Controls.A dd"-ed IFRAME tags only contains the one requested
by the most recent PostBack. Instead of creating the running, cumulative
collection of IFRAMEs with each LinkButton click that I'm looking for, the
Panel dumps everything and starts over with what was just requested.

I understand this probably has something to do with Page.Load and ViewState,
but I'm unclear as to how to address it specifically. Please help!

Thanks much,
Chris
Nov 19 '05 #1
1 1452
I posted a sample a while back on how to do this:

http://groups-beta.google.com/group/...717a97bd32c450

It's not doing exactly what you want, but the main thing is that you need
to recreate the controls upon every postback.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi there:

I've checked the forums, but haven't found a situation addressing my
specific problem. Here's the deal:

I've got a Web Form containing two Panel controls. One displays
search results in a DataList comprised mainly of LinkButtons. The
other's basically empty; it's intended to handle a collection of
dynamically added controls.

When the user clicks a LinkButton from within the first Panel control,
I want to be able to take the argument passed by that click and add,
to the second Panel control, an IFRAME tag with a reference to load
from a URL based on what the user clicked. This panel should be able
to contain one 'n' IFRAME tags.

The problem I'm having is that with each PostBack, the Panel that's
supposed to contain the "Controls.A dd"-ed IFRAME tags only contains
the one requested by the most recent PostBack. Instead of creating
the running, cumulative collection of IFRAMEs with each LinkButton
click that I'm looking for, the Panel dumps everything and starts over
with what was just requested.

I understand this probably has something to do with Page.Load and
ViewState, but I'm unclear as to how to address it specifically.
Please help!

Thanks much,
Chris


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5479
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
1
2119
by: Craig Buchanan | last post by:
i am building a webform that dynamically loads one of two web usercontrols during the webform's page_load event. during the postback i reload the appropriate web usercontrol. so far so good. unfortunately, none of the controls, except a label, have any values. what am i not doing? all the controls on the WUC have enableviewstate set to true. thanks,
10
4507
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back (basically have the data binding done in the If NOT IsPostBack Then statement). How come? How does this information get preserved? Which raises another question. Becuase I want to get away from the spaghetti code approach, I would like to create...
1
3355
by: John Cosmas | last post by:
I've got a page which loads up a different user control into a placeholder control every time a button is clicked on the parent page. I use a statement like Me.plcTabViews.Controls.Add(LoadControl("test.ascx")). There are up to 30 possibilities which are decided by CASE statements and keeps one from loading up onto another. However, I'm running into a unique error... Failed to load viewstate. The control tree into which viewstate is...
2
4230
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 Visible = false on this detailsView. And rebound appropriate gridView. Then I press the button and I have exception: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save...
4
3862
by: Gregory Gadow | last post by:
If there is a more appropriate forum, please let me know and I will post there. Our field reps can go on to our website and select from several sets of data to create the address we then provide to their clients in company correspondence. Using just name as an example, one rep might have a choice between "James Smith", "James Smith MS, CFP, MBA" and "Jimmy Smith" while a different rep might have only "Elizabeth Jones" and "Liz Jones."...
3
2191
by: Ben Dewey | last post by:
Okay, so I have a base Page class called ArticlesPageBase. This base class has reads in an overridable ArticleId and Loads the data into a Panel object in the ContentPlaceHolder of the Master. The article that it loads from the Database is a xml field that contains html code for the article. I added some custom html to the database article called <question id="22" /> When the article contains inline questions are parse out the start...
1
3011
by: RSH | last post by:
Hi, I am experimenting with the Viewstate and based on a few articles I have read, I put together a test. it is a simple test where I am dynamically creating a DropDownList that contains 25000 list items. When I don't create the control dynamically, I get a viewstate that is roughly 1 mb in size! However, when i use the code below the viewstate is 0 bytes even on postback. Impressive size difference. Now where I get perplexed is even...
0
1651
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 item which was selected in the previous run the following error message is displayed.. Please help me in this regard.. Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9026
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.