Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Failed to load viewstate when dynamically adding controls in placeholders

Reply
Thread Tools

Failed to load viewstate when dynamically adding controls in placeholders

 
 
Sinisa Ruzin
Guest
Posts: n/a
 
      10-07-2004
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--
 
Reply With Quote
 
 
 
Reply

Thread Tools

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Placeholders or One to load controls tshad ASP .Net 6 08-01-2007 03:54 PM
Errors: Failed to load viewstate. & Validation of viewstate MAC failed. sck10 ASP .Net 6 09-01-2006 05:59 PM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net Building Controls 1 05-26-2004 06:41 AM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net Web Controls 1 05-26-2004 06:41 AM
Passing Parameters to User Controls that are Dynamically Loaded in Placeholders Josh ASP .Net 1 05-26-2004 12:42 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57