Month: September 2013

SharePoint DateTime control not loading for some user (DateTimeControl Access denied )

It is a permission issue.
 
DateTimeControl field uses the iframe calender page to render the actual calender. The location of iframe.aspx is C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
The problem appeared to be with managed paths in the site collections, the Users with “Contribute access” were accessing the following path:
http://myserver/_layouts/iframe.aspx (Path to Root site collection where user doesn’t have access)
 
 
The solution:

DateTimeControl .DatePickerFrameUrl =SPContext.Current.Web.Url+”/_layouts/iframe.aspx “;
Or
DatePickerFrameUrl = “” DateOnly=”true” runat=”server” />
~site/ is an equivalent to SPContext.Current.Web.ServerRelativeUrl
~sitecollection/  is an equivalent to SPContext.Current.Site.ServerRelativeUrl
Advertisements

Why to Dispose SPSite and SPWeb objects in SharePoint?

Several of the SharePoint Foundation objects, primarily the SPSiteclass and SPWebclass objects, are created as managed objects. However, these objects use unmanaged code and memory to perform the majority of their work. The managed part of the object is much smaller than the unmanaged part. Because the smaller managed part does not put memory pressure on the garbage collector, the garbage collector does not release the object from memory in a timely manner. The object’s use of a large amount of unmanaged memory can cause some of the unusual behaviors described earlier. Calling applications that work with IDisposable objects in SharePoint Foundation must dispose the objects when the applications finish using them. You should not rely on the garbage collector to release them from memory automatically.

Each instance of SPSite and SPWeb contains a reference to an SPRequest object that, in turn, contains a reference to an unmanaged COM object that handles communications with the database server. SharePoint Foundation monitors the number of SPRequest objects that exist in each specific thread and in parallel threads, and adds useful entries to the logs under the three following scenarios:
  • The total number of SPRequest objects exceeds a configurable threshold.
  • An SPRequest object continues to exist at the end of a thread.
  • An SPRequest object was removed from the heap by garbage collection