Matthias
  • Member for 11 years, 4 months
  • Last seen more than a month ago
Get Site Collection full URL using javascript
14 votes

You can do it like this: <script> function GetSiteUrl() { var ctx = new SP.ClientContext(); var site = ctx.get_site(); ctx.load(site); ctx.executeQueryAsync(function(s, a){...

View answer
Show folders in document library that have a filter view
Accepted answer
11 votes

Or "Content Type" is equal to "Folder": NOTE FOR SHAREPOINT ONLINE: This filter won't work on Sharepoint online. Here's is the answer to filter by type folder : View only Folder ...

View answer
Race condition in SPListEventReceiver.ListAdded - Save Conflict
Accepted answer
9 votes

You have to register the ItemAdded event as Synchronous event. SPEventReceiverSynchronization.Synchronous You can define it programmatically: http://msdn.microsoft.com/en-us/library/microsoft....

View answer
Which Site Template is a site using?
7 votes

By using Powershell: add-pssnapin "Microsoft.SharePoint.PowerShell" $s = get-spsite "http://localhost" #this will resolve the name $name = $s.RootWeb.WebTemplate #this will resolve the id $id = $s....

View answer
How to get current SPListItem from web part on edit form?
Accepted answer
6 votes

Have you already tried SPContext.Current.ListItem?

View answer
Get UniqueId from listitem with Javascript/Ecmascript (Sharepoint 2010)
Accepted answer
6 votes

Here is a script that gets the UniqueId of a list item: <script type="text/javascript"> $(document).ready(function() { ExecuteOrDelayUntilScriptLoaded( function() ...

View answer
How do I get machine name off of the SPContext
Accepted answer
5 votes

Maybe SPServer.Local is what you are looking for...

View answer
.Webs and anonymous access?
Accepted answer
5 votes

You could open the site with the SystemAccount token. It is more recommended than using SPSecurity.RunWithElevatedPrivileges. I would do it like this: private void LoadSubsites() { using (SPSite ...

View answer
How to disable a ribbon button when a folder is selected
Accepted answer
5 votes

Use the fsObjType property: EnabledScript="javascript: var items = SP.ListOperation.Selection.getSelectedItems(); (items.length == 1 &amp;&amp; items[0].fsObjType == 0);"

View answer
how to programetically get the type (TemplateType) of a Library using the item url
Accepted answer
4 votes

using (SPSite site = new SPSite(<siteUrl>) { using (SPWeb web = site.OpenWeb()) { SPList list = web.GetList(<imageUrl>); SPListTemplateType templateType = list.BaseTemplate; ...

View answer
Item added or item edited Sharepoint 2010 event receiver
Accepted answer
4 votes

ItemAdding/ItemAdded is only triggered once, when the item is created. I guess for your problem it would be the ItemUpdating event: public override void ItemUpdating(SPItemEventProperties properties) ...

View answer
Access denied when registering a custom timer job
4 votes

Try to override the SPPersistedObject.HasAdditionalUpdateAccess() method and return true. protected override bool HasAdditionalUpdateAccess() { return true; }

View answer
Download file from a sharepoint site from code behind
4 votes

You can construct the attachment URL by using the SPAttachmentCollection.UrlPrefix property of the attachments collection. For example: string attachmentUrl = item.Attachments.UrlPrefix + item....

View answer
How to open a SharePoint page without the master page?
4 votes

Just append IsDlg=1 to your URL. The open in dialog is not controlled by the IsDlg=1 parameter. To avoid opening the edit/view form of a list item in a dialog, you can also set the "Launch forms in a ...

View answer
Sharepoint 2010 Taxonomy 3rd party replacement?
Accepted answer
3 votes

Take a look at MatchPoint for SharePoint (where I am working for). It comes with it's own metadata management, but also supports the ootb taxomomy stuff.

View answer
User control in delegate control
Accepted answer
3 votes

I think the error message states that your UserControl (CustomNavUserControl.ascx) does not implement IHierarchicalDataSource. So your code behind file (CustomNavUserControl.ascx.cs) of your ...

View answer
SPSecurity.CatchAccessDeniedException = false: Does Sharepoint keep this setting?
Accepted answer
3 votes

It is kept inside the current HttpContext. If you decompile the code you will see it: public static bool CatchAccessDeniedException { get { HttpContext current = HttpContext.Current; if (...

View answer
Sharepoint foundation 2010 on mac
3 votes

There is a browser compatibility overview from Microsoft: http://technet.microsoft.com/en-us/library/cc288142.aspx

View answer
Not sure how to programmatically filter by taxonomy metadata in my custom search webpart
3 votes

If you create your own ManagedProperty, e.g. 'Terms' and map it to the crawled property 'ows_taxId_MetadataAllTagsInfo', then you can use in your FullTextSqlQuery a condition like: Terms = '#0[TERM ...

View answer
Disposal of SPWebs retrieved from SPContext.Current.Site.AllWebs
3 votes

I think you have to dispose the SPWeb objects when retrieved from the SPSite.AllWebs collection. If you have look at the implementation of the SPWebCollection class by decompiling it, you can see that ...

View answer
What is the recommended best practice for updating a SharePoint Solution (WSP)?
3 votes

Call Update-SPSolution without the -local parameter on any server in your farm. As far as I know, an update timer job is automatically scheduled, which updates the solution on every server, where the ...

View answer
How to properly use the Using Statement with SharePoint Objects
3 votes

There is a best practices guide from microsoft about when to dispose which objects (SPSite, SPWeb): http://msdn.microsoft.com/en-us/library/ee557362(v=office.14).aspx Also there is a dispose checker ...

View answer
How to detect if my code is running inside SPSecurity.RunWithElevatedPrivileges
Accepted answer
2 votes

This is finally the solution I came to: public static bool IsPrivilegedMode() { using (WindowsIdentity identity = WindowsIdentity.GetCurrent()) { return identity != null && ...

View answer
Possible to use DateOnly with the DateTimeField control?
Accepted answer
2 votes

The DateTimeField uses internally a DateTimeControl on which the DateOnly value is set (passed through). But this internal DateTimeControl is not instantiated in the CreateChildControls method of the ...

View answer
SharePoint save content in session
Accepted answer
2 votes

Here are some considerations: You could enable the session. There are several blogs or forum posts about that (like https://stackoverflow.com/questions/2237989/enabling-session-state-in-sharepoint-...

View answer
Modifying a document when uploaded
Accepted answer
2 votes

Maybe you have to register the ItemAdded event as Synchronous event. See this answer how to do it: Race condition in SPListEventReceiver.ListAdded - Save Conflict

View answer
Is there a way to automatically send major document versions to a Records Center while keeping the primary document active?
2 votes

You could implement a TimerJob, which copies the major versions of the documents to another document library every night or another interval. Otherwise implement an SPItemEventReceiver, that also ...

View answer
Custom Field Type not saving properties?
2 votes

I was also facing this problem and I analyzed with a decompiler tool the creation of a custom field type with an editor control. The problem is that when the new column of your field type is created a ...

View answer
Deploying DevExpress (third party) controls on SharePoint
Accepted answer
2 votes

I think, the problem is on line 1. There you specify an Inherits attribute together with the Codebehind attribute. You probably can't specify them togheter as specified here: http://msdn.microsoft.com/...

View answer
How to add web part (lvwp) programatically in SP2010?
Accepted answer
2 votes

SPWeb web = ... PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(web); PublishingPage page = pWeb.GetPublishingPage(<pageUrl>); SPFile file = page.ListItem.File; SPLimitedWebPartManager mgr = ...

View answer