Disable Viewstate in bulk
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
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();
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?
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
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!!!
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!!!