Setting BrowserFileHandling programmatically in SharePoint 2010?
I am trying to set all lists/libraries that has BrowserFileHandling set to strict to permissive. I had a look at http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbrowserfilehandling.aspx so I want check if status is 1 and set it to 0 but I can't get it to work.
With the code (example):
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsite = oSiteCollection.AllWebs;
foreach (SPWeb web in collWebsite)
{
web.AllowUnsafeUpdates = true;
SPListCollection collList = web.Lists;
foreach (SPList oList in collList)
{
oList.BrowserFileHandl开发者_如何转开发ing = 0;
}
}
I can set all list's browserfilehandling to permissive. But if I want to test and set all to strict again and change the 0 to 1 I get
"Cannot implicitily convert type int to Microsoft.SharePoint.SPBrowserFileHandling"
Why can I set it to 0 but not to 1?
I wanted to do a check something like:
if(oList.BrowserFileHandling == 1)
{
//set to 0
}
but it doesn't work, what do I need to do here?
Thanks in advance.
Set it either by using
oList.BrowserFileHandling = SPBrowserFileHandling.Permissive;
or
oList.BrowserFileHandling = SPBrowserFileHandling.Strict;
So change your codes to
if (oList.BrowserFileHandling == SPBrowserFileHandling.Permissive)
{
oList.BrowserFileHandling = SPBrowserFileHandling.Strict;
}
精彩评论