Disable Viewstate in bulk

Posted by Community Admin on 03-Aug-2018 01:36

Disable Viewstate in bulk

All Replies

Posted by Community Admin on 06-Oct-2011 00:00

Hi,
I was just wondering is there a quick SQL script I can run to disable the viewstate on all pages?  I have about 200 pages of which probably 95% are static content and don't need viewstate yet its turned on for all pages at the moment.  So it would be quicker to disable for all then just renable for the 5% that do need it.
Thanks
Byron

Posted by Community Admin on 06-Oct-2011 00:00

Hi Byzza,

By default we have ViewState disabled on all pages, the behavior you are reporting is really strange. However, you can easily set it to false for all pages using the pages API. For example:

App.WorkWith().Pages()
              .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend)
              .ThatArePublished()
              .Where(p => p.Page != null)
              .ForEach(p =>
              
                  p.Page.EnableViewState = false;
              ).SaveChanges();



Greetings,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Oct-2011 00:00

Hi Boyan,

Thanks for the quick reply.  I will try this today.

This site was an upgrade from 3.7 would that be the reason they all have viewstate enabled?

Posted by Community Admin on 07-Oct-2011 00:00

Hi Byzza,

Thanks for the clarification, yes in Sitefinity 3.x we had ViewState enabled globally( you can set ti to false for all pages from the web.config), that's the most likely reason.

Regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 06-Jul-2012 00:00

Hey guys, I'm not a .Net programmer; how do you execute this code using the API? Specifically, where do I load this code? How do I load this and run it? Thanks!!!

Posted by Community Admin on 06-Jul-2012 00:00

Hey guys, I'm not a .Net programmer; how do you execute this code using the API? Specifically, where do I load this code? How do I load this and run it? Thanks!!!

This thread is closed