This is a migrated thread and some comments may be shown as answers.

Failed to load view state error when moving dynamically created widgets around the raddocklayout

29 Answers 972 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Martin Beeby
Top achievements
Rank 1
Martin Beeby asked on 21 Sep 2007, 04:55 PM

29 Answers, 1 is accepted

Sort by
0
Guy
Top achievements
Rank 1
answered on 29 Oct 2007, 04:15 PM
Martin,

This appears to be the fix i am looking for, however i get an unknown tag error when i load the page.

i followed the instructions exactly as you wrote them but for some reason a parser error occurs telling me that the tag prefix is not registered.

Have telerik actually fixed this themselves yet?
0
Martin Beeby
Top achievements
Rank 1
answered on 29 Oct 2007, 04:20 PM
It's not so much a problem with the control, it's really a problem with the demo.

Did you modify your web config file and add <add tagPrefix="Martinbeeby" namespace="Martinbeeby.Core.Controls"/>  ?

This is what registers the control with your application so that you can use it without compiling the code.

0
Guy
Top achievements
Rank 1
answered on 29 Oct 2007, 04:42 PM
Hi Martin,

I certainly did. i get the error

Parser Error Message:
Unknown server tag 'Martinbeeby:RadDockLayoutNew'.

In objectBrowser the fully qualified namespace of the classes comes up as Infonetica.Red.Martinbeeby.Core.Controls however i have tried the web.config with just your namespace and with the one stated above.

After changing the tag prefixes in the aspx page and switching to design view everything looks ok. its just when i run it.

What is the root namespace of the project that you created the class in? this could be where im getting it wrong, as yours may have overlap by default.

I fully understand the source of the issue that you wrote up, but was really struggling to find a workaround to it until i saw your post.  thanks for your help so far.

Ive spent the last 4 days trying to think of a better way to engineer the whole layout thing to workaround this issue and a couple more such as different zone layouts per user etc..
0
Martin Beeby
Top achievements
Rank 1
answered on 29 Oct 2007, 04:49 PM
Yes sounds like that's the problem.

In the example I added here the default namespace is MartinBeeby.

Have you nested this namespace inside your own namespace?

prehaps you could send me the project zipped up and i could take a look? Or is the file too big?
0
Guy
Top achievements
Rank 1
answered on 29 Oct 2007, 04:59 PM
Hi Martin,

Im pleased to say i got it working - the page required a register directive for the tagPrefix because it is not marked on the assembly (which can be done in assemblyInfo if necessary).

i got the clue from the following link, although im using web app projects so had to modify the assembly reference to my own dll as app_code directory does not exist.... http://alpascual.com/blog/al/archive/2007/04/30/Fixing-the-error-Unknown-server-tag-when-you-create-or-inherit-a-control-on-App_5F00_code-folder.aspx

Many thanks for your help, you have no idea how grateful i am! :-D

Regards,
Guy
0
Martin Beeby
Top achievements
Rank 1
answered on 29 Oct 2007, 05:06 PM

One last thing, There is a slight bug with the code below.

I haven't had a chance to fix it properly, but i do have a work around. The add button on the portal can still create view state problems.

One of our testers discovered a bug that when you add more than one new widget to you page in one session. The veiwstate gets applied from the first control to the second control.

This has something to do with the page control hierarchy, as the control is added to the updatepanel and not to the raddock.

My work around is to simply remove the Ajax link on the add button. (It sucks I know) So that the button causes postback.

To be honest this works fine for my needs and I didn't have time to investigate the problem completely.

0
Guy
Top achievements
Rank 1
answered on 30 Oct 2007, 09:44 AM
ok, thanks for the heads up.

i havent been able to reproduce the bug you speak of but will keep an eye out for it.

incase anyone else needs this solution, the best way to make it work is the following....

follow martins instructions for all the code, but set the namespace in the class to something of your choice - i used 'Fixes'.

because the root namespace for my web project is already GHC this means that these classes live in the namespace GHC.Fixes

so in your web.config where you add the tagprefix put the full namespace for the class also... Note that my tags will be prefixed with 'Fixes' rather than 'martinbeeby'
<system.web>
<add tagPrefix="Fixes" namespace="GHC.Fixes"/>

Then in each page that you use these new controls you must add a register directive at the top of the page like so...

<%@ Register TagPrefix="Fixes" NameSpace="GHC.Fixes" Assembly="GHC" %>

The Assembly attribute is the name of the dll (minus the extension) that contains the controls.  My dll compiles down to GHC.dll so my assembly attribute has a value of GHC.

ns2.discountasp.net

0
Martin Beeby
Top achievements
Rank 1
answered on 30 Oct 2007, 09:52 AM

Ok what the mistake may have been

You don't need the <%@ Register TagPrefix="Fixes" NameSpace="GHC.Fixes" Assembly="GHC" %> on each page

Thats what the <add tagPrefix="Fixes" namespace="GHC.Fixes"/> is for.

How ever you probably need to register the namespace in the web config as below:

<pages enableEventValidation="false">  
<namespaces> 
            <add namespace="Martinbeeby.Core"/>  
            </namespaces> 
 <controls> 
 <add tagPrefix="Martinbeeby" namespace="Martinbeeby.Core.Controls"/>   
    <!-- added line below for ajax support --> 
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>  
   </controls> 
  </pages> 


 

0
Bnva1
Top achievements
Rank 1
answered on 13 Mar 2008, 01:56 PM
Martin,

You are the man - been banging my head against the wall with this VS error for a few days.  Your fix worked like a charm.  This thread is pretty old, I don't understand why Telerik hasn't incorporated your fix into the latest 2 releases.

Thanks again,
Brian
0
Martin Beeby
Top achievements
Rank 1
answered on 13 Mar 2008, 02:04 PM

I'm really glad this post helped. I'm not sure why the problem hasn't been addessed in the latest versions of the controls.

I guess It's not really a problem with the dock control. Its more a limitation of the portal demo.

Who cares I guess. As with most things, once you understand the problem it's pretty easy to fix.

0
Jerald Carter
Top achievements
Rank 1
answered on 30 Dec 2008, 07:29 PM
Beautiful!

Worked like a charm!
0
Joseph
Top achievements
Rank 1
answered on 30 Dec 2008, 09:01 PM
The fix worked for me as well.  ViewStateModeById is a wonderful thing.  This is a .NET thing of course and not really a Telerik issue.  Anytime I add dynamic controls to a page now, my standard practice is to subclass the control and use ViewStateModeById.  Thanks again Martin.

joseph
0
Stuart
Top achievements
Rank 1
answered on 02 Feb 2009, 03:55 PM
Just wanted to say a big thank you for posting this fix. I too have spent time trying to work out the issue and your fix worked like a dream.

Cheers,
Stuart,

0
Sameer
Top achievements
Rank 1
answered on 12 Feb 2009, 02:01 PM
Another success Martin.You saved me..

It should be marked as very IMP fix.
People would save lot of time if coded like that to begin with (but then they will not realize how tough it was otherwise :) )


0
Martin Beeby
Top achievements
Rank 1
answered on 12 Feb 2009, 02:23 PM
Thanks for the feedback. The fact that people are still using this and also being so kind with the replies makes me glad I made this post over 1 and 1/2 years ago!

Cheers Martin
http://www.thewayithink.co.uk
0
Cradz
Top achievements
Rank 1
answered on 05 Feb 2010, 05:58 PM
Just wanted to say thank you.

This fixed the issue I was having too.
0
Andreas
Top achievements
Rank 1
answered on 20 May 2010, 09:21 AM
I just wanted to say thank you too. It solved the problem we had for a time now.

//andii
0
HL
Top achievements
Rank 1
answered on 16 Aug 2010, 09:10 PM
I just want to say -- yuo saved me lots of time and I appreciate you post the answer. I am so disappointed that Telerik didn't fix it till now and it cost me several days for this issue. THANK-YOU !!!!

Thanks
Helena
0
Dongwook Kim
Top achievements
Rank 1
answered on 15 Sep 2010, 08:29 PM
Hi,

I really want to try the code in c# but I'm having an error, tye type or namespace name 'ViewStateModeByIdAttribute could not be found.

Any solutions?

thanks,
Ryan
0
Andreas
Top achievements
Rank 1
answered on 16 Sep 2010, 07:42 AM
You need to add a reference to System.Web
and then you need add this to the class

 

 

 

 

using System.Web.UI.WebControls;

 

 

 

 

 

 

 

 

 

 

 

 

0
Dongwook Kim
Top achievements
Rank 1
answered on 16 Sep 2010, 11:48 PM
Hi,

Thanks you for your solutions. I haven't tried it yet but I have a question.
After removing a dock or docks, I got the "failed to load viewstate" error when it posted back to server specially the the dock or docks contains the control using viewstate such as radgrid(paging) or controls(textbox) with button.

does Anybody know it will solve the my issues?

Thanks,
DW
0
Andreas
Top achievements
Rank 1
answered on 17 Sep 2010, 07:05 AM
Yes, that should take care of your problem.
0
afishisafish
Top achievements
Rank 1
answered on 20 Jan 2011, 03:21 PM
Thank you for sharing, very helpful solution... cheerz!
0
Christopher Warin
Top achievements
Rank 1
answered on 20 Jan 2011, 06:06 PM
This fixed my issue also. My thinking is that on the first load you add the raddocks to the radlayout control But after a certain number of postbacks or raddock moves the controls are in the raddockzones rather than in the radlayout as set in oninit?  Not sure but I wish this was part of a service pack. Telerik definetly needs to look into this fix and explain why are the implications of using ViewStateModeById
0
Pero
Telerik team
answered on 21 Jan 2011, 05:16 PM
Hello,

The main reason why the RadDock class is not marked with the ViewStateModeById attribute is because of the performance cost when loading the ViewState information.
The ViewState problems with the RadDock control come from the fact that after closing a given dock it is not recreated on the next postback, and its ViewState information is loaded to another control placed on its spot in the Controls tree of the Page.

For the time being the suggested solution for resolving ViewState problems in applications that are highly dependent on the ViewState, is inheriting the RadDock class and marking it with the ViewStateModeById attribute.

Kind regards,
Pero
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Michael
Top achievements
Rank 1
answered on 25 May 2012, 08:46 AM
I was having the same issue ... but when I applied this work around I am getting this error message on runtime

"The base class includes the field 'RadDockZoneM', but its type (Martinbeeby.Core.Controls.RadDockZoneNew) is not compatible with the type of control (Martinbeeby.Core.Controls.RadDockZoneNew).
"

I have cleaned my solution , rebuilt it, removed Telerik.Web.UI refernces and re-added it. I re-organized the folders but still I can'f figure out why this is happening

In my scenario I only need to decalre a RadDockLayout and a RadDockZone .. the actual RadDocks will be added dynamically in the zone.

Some help will be much appriciated.

Thanks in advance
0
Pero
Telerik team
answered on 28 May 2012, 02:39 PM
Hi Michael,

Is it possible that you might have a circular reference in your project.  Could you please follow the instructions in the links below and see the issues will be resolved?

http://connect.microsoft.com/VisualStudio/feedback/details/104839/the-base-class-includes-the-field-but-its-type-is-not-compatible-with-the-type-of-control

http://support.microsoft.com/kb/919284

All the best,
Pero
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Michael
Top achievements
Rank 1
answered on 30 May 2012, 10:07 AM
Hi,

I managed to fix the problem by adding the MartinBeeby Class in a seperate class library and it worked.

But it seems it is only partially working. In my zones I dynamically add UserControls. Although I am keeping the items in the RadComboBox for example..  but I am loosing the selected/checked items after postbacks and even the text inputted...

Thanks againg
0
Slav
Telerik team
answered on 31 May 2012, 11:59 AM
Hi Michael,

Please check the online demo My Portal as it implements loading of user controls in dynamically added RadDock controls and can be used as a base for achieving the same on your end.

Note the I am willing to help you, but currently I am mostly guessing as to what your setup is. If you are still having difficulties, please open a support ticket and send a simple, runnable page that isolates the problem so that I can inspect it locally and suggest a concrete solution.

Regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Dock
Asked by
Martin Beeby
Top achievements
Rank 1
Answers by
Guy
Top achievements
Rank 1
Martin Beeby
Top achievements
Rank 1
Bnva1
Top achievements
Rank 1
Jerald Carter
Top achievements
Rank 1
Joseph
Top achievements
Rank 1
Stuart
Top achievements
Rank 1
Sameer
Top achievements
Rank 1
Cradz
Top achievements
Rank 1
Andreas
Top achievements
Rank 1
HL
Top achievements
Rank 1
Dongwook Kim
Top achievements
Rank 1
afishisafish
Top achievements
Rank 1
Christopher Warin
Top achievements
Rank 1
Pero
Telerik team
Michael
Top achievements
Rank 1
Slav
Telerik team
Share this question
or