+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Disable Viewstate in bulk

Disable Viewstate in bulk

6 posts, 0 answered
  1. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    06 Oct 2011
    Link to this post
    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
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    02 Dec 2016
    06 Oct 2011
    Link to this post
    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
  3. Byzza
    Byzza avatar
    89 posts
    Registered:
    09 Jul 2007
    06 Oct 2011
    Link to this post
    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?
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    02 Dec 2016
    07 Oct 2011
    Link to this post
    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
  5. catoegroup
    catoegroup avatar
    21 posts
    Registered:
    23 Apr 2010
    06 Jul 2012
    Link to this post
    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!!!
  6. catoegroup
    catoegroup avatar
    21 posts
    Registered:
    23 Apr 2010
    06 Jul 2012
    Link to this post
    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!!!
6 posts, 0 answered