473,387 Members | 1,592 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,387 software developers and data experts.

Failed to load viewstate when dynamically adding controls in placeholders

Hi all,
I had problem with dynamically adding/removing controls;ascx,
Controls.Add(Page.LoadControl... in the same page of the IBuySpy
portal. ASP.NET, C#.
I added buttons to the main ASCX loaded by desktopdefault.aspx. The
buttons were used to "navigate" withing the same page. I had the
problem with "fail to load viewstate ...." due to a mismatch controls
in the treeview in the viewstate. Dynamically removing controls was
messy and it did not work in some cases.
I figured out that if I add an additional argument in the URL and
assign the url to each of the buttons, then I effectively submit
different urls each time I click any of the buttons despite the fact
that I am still in "the same page(ascx).

Example:

Main URL to my page:
http://localhost/VITRUAL_DIR/Desktop...dex=4&tabid=19

The buttons redirect to:
http://localhost/VIRTUAL_DIR/Desktop...=19&subtabid=1
http://localhost/VIRTUAL_DIR/Desktop...=19&subtabid=2
and so on.
I actually use subtabid to know where in the Page the user is, but if
you don't need it, you can use a dummy parm every time you change your
control list. I believe that the result will be tricking ASP engine
into not using the Viewstate to reconstruct the control states, since
the URL is now different;
Example:
http://localhost/VIRTUAL_DIR/Desktop...ed2newControls

http://localhost/VIRTUAL_DIR/Desktop...orenewControls

I'd like to hear comments on this workaround. I was trying to find a
simple solution for quite few hours in the user groups, but nothing
similar was suggested.
Cheers,
Sinisa Ruzin(contact aaAT itdesign-inc.com)
http://www.itdesign-inc.com
-- Custom Web Solutions--
Nov 18 '05 #1
0 1702

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

Similar topics

3
by: Eamonn O'Connell | last post by:
Hi, We have an ASP.net application, where we dynamically add controls, in the Page_Load. Occasionally, when the user posts back the page (e.g. clicks Save button on the page), we get a "Failed...
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...
2
by: Mike Hnatt | last post by:
I normally try to post more helpful subject lines. But in this case, after tons of development, my app suddenly works no more. Here is the message: I get this on the page postback when it...
1
by: et | last post by:
I. Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For...
1
by: rockdale | last post by:
Sometime my ASP.NET application got this error message but not always everytime. Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that...
6
by: sck10 | last post by:
Hello, I have applications that produce the following error when they have been open to long without activity. Is there any way to force a re-load of the page or go to another page if the page...
2
by: sck10 | last post by:
Hello, I have a web page that has a GridView and a FormView, each in its own panel. The GridView shows a list of records in a database. When a row in the GridView is selected the FormView...
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...
2
by: Rotsey | last post by:
Hi, I have a web site that uses user controls to display different formats of timesheets. I have a browse page that has prev/next buttons to browse through a set of timesheets. As I say...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.