How to set/retrieve web part properties.
http://www.sharemuch.com/2010/05/25/referencing-web-part-properties-in-sharepoint-2010-visual-web-part/
Tuesday, January 25, 2011
Web Part install/uninstall
Add-SPSolution -LiteralPath
Install-SPSolution -Identity-AllWebApplications -GACDeployment
Uninstall-SPSolution -Identity
Remove-SPSolution -Identity
Install-SPSolution -Identity
Uninstall-SPSolution -Identity
Remove-SPSolution -Identity
Friday, January 21, 2011
The annoying, "The site is not valid. The 'Pages' document library is missing" error when trying to set the DefaultPage property for a website.
The DefaultPage property points to a page in the PagesList, so the PagesList must be set to a valid document library before the DefaultPage property can be set.
Here's how to do this:
SPWeb newSite = mySite.Webs.Add(subsiteUrl, subsiteTitle, subsiteDescription, 1033, currentTemplate, true, false);
newSite.Update();
SPFile welcomePage = newSite.Folders[pagesFolder].Files[defaultPage];
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(newSite);
pubWeb.PagesListId = newSite.Folders[pagesFolder].DocumentLibrary.ID;
pubWeb.Update();
pubWeb.DefaultPage = welcomePage;
pubWeb.Update();
The DefaultPage property points to a page in the PagesList, so the PagesList must be set to a valid document library before the DefaultPage property can be set.
Here's how to do this:
SPWeb newSite = mySite.Webs.Add(subsiteUrl, subsiteTitle, subsiteDescription, 1033, currentTemplate, true, false);
newSite.Update();
SPFile welcomePage = newSite.Folders[pagesFolder].Files[defaultPage];
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(newSite);
pubWeb.PagesListId = newSite.Folders[pagesFolder].DocumentLibrary.ID;
pubWeb.Update();
pubWeb.DefaultPage = welcomePage;
pubWeb.Update();
Friday, January 14, 2011
Writing to Trace Log
Here’s some sample code for writing to the trace log.
using Microsoft.SharePoint.Administration;
private void WriteTraceLog(string logEntry)
{
SPDiagnosticsService diagnosticsService = SPDiagnosticsService.Local; SPDiagnosticsCategory cat = diagnosticsService.Areas["SharePoint Foundation"].Categories["Unknown"];
diagnosticsService.WriteTrace(1, cat, TraceSeverity.Medium, logEntry, cat.Name, cat.Area.Name);
}
The logfile’s here: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS(SP creates a new logfile every 30 minutes.)
References:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spdiagnosticsservicebase.writetrace.aspx
http://technet.microsoft.com/en-us/library/ee748656.aspx
http://msdn.microsoft.com/hi-in/library/aa979590(en-us).aspx
Administrators can use the LogLocation property of the SPDiagnosticsService class to specify the location of the trace log to which to write.The actual registry key that specifies the location of the trace log is called LogDir and is located at the following location:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\WSS]
However, you should never edit this value directly.
(This usually defaults to: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS)
using Microsoft.SharePoint.Administration;
private void WriteTraceLog(string logEntry)
{
SPDiagnosticsService diagnosticsService = SPDiagnosticsService.Local; SPDiagnosticsCategory cat = diagnosticsService.Areas["SharePoint Foundation"].Categories["Unknown"];
diagnosticsService.WriteTrace(1, cat, TraceSeverity.Medium, logEntry, cat.Name, cat.Area.Name);
}
The logfile’s here: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS(SP creates a new logfile every 30 minutes.)
References:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spdiagnosticsservicebase.writetrace.aspx
http://technet.microsoft.com/en-us/library/ee748656.aspx
http://msdn.microsoft.com/hi-in/library/aa979590(en-us).aspx
Administrators can use the LogLocation property of the SPDiagnosticsService class to specify the location of the trace log to which to write.The actual registry key that specifies the location of the trace log is called LogDir and is located at the following location:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\12.0\WSS]
However, you should never edit this value directly.
(This usually defaults to: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS)
Subscribe to:
Posts (Atom)