Thursday, February 3, 2011

Map folder in SharePoint Root

I am sure many of you needed from time to time to get a local path to a file that was deployed to the SharePoint Root (AKA Hive in 2007 version, AKA “12” folder AKA “14” folder).

For whatever reason you needed to do so, you probably notices that the ASP.NET API (Server.MapPath) or any other ASP.NET method of discovering the local path for a file or folder did not work out as excepted.

Without going into a long explanation on why that did not work, There is a very little documented method that I have used a lot in the past and I have learned not many developer know it.

The SPUtility class contains a static method named “GetGenericSetupPath” that takes one string parameter.

That string parameter can be any folder under the SharePoint Root folder, and the result of the method is the local file system path of that folder.

For example, to get the local path for “Template” folder, use this command:
SPUtility.GetGenericSetupPath("Template");

But to get the “Layouts” folder, you have to use this command:
SPUtility.GetGenericSetupPath("Template\\LAYOUTS");

Now, saying that – you have to keep in mind that although you do have read permissions to these folders while inside a SharePoint APP, other permissions (like create file, or create folders) may be blocked.

Cheers,

Shai.

Tuesday, February 1, 2011

How to identify a Ribbon control ID

A frequent question I get during my “How to develop for the SharePoint Ribbon” session is:

How can I identify and existing ribbon control or group ID?

This is useful when you wish to override, hide a control, or insert new controls into an existing group / new groups into an existing tab.

So, this task is pretty simple once you know this trick:

First, open a page and make your ribbon control visible:

image

Second, use IE developer tool bar to select the ribbon button you want:

image

 

Climb up the HTML to the span container, the span ID will have the ribbon control ID:

image

In my case, for the wiki page “email a link” here is what we get:

Ribbon.WikiPageTab.Share-LargeLarge-0-0

So, the control ID will be:

“Ribbon.WikiPageTab.Share”

And there you go!

Tuesday, November 30, 2010

Google Chrome uses IE login information

Does Google chrome uses IE login settings and information?

No… that would be crazy, right?

But – how else would explain this strange behaviour:

I have a SharePoint site that supports anonymous login. I have IE open and logged in to the site as user A, and in the site the is a tasks list that does not allow anonymous users to view items.

When I opened chrome and browsed to the site home page – as expected, I was still anonymous to the site. But as soon as I hit the link to the tasks list – it logged me in as user A, without even asking for my credentials!

So, Google chrome does not ask for login information? Does it share the login information with IE? This is kind of troubling if true, as so far I used several browsers to make sure I get isolated sessions and logins.

So, I opened IE internet options –> security settings and forced IE to work in anonymous mode only:
image

Now, when I open Chrome and try to access that list it prompts me for user name and password before it logs in.

Am I the only one surprised?