Monday, April 23, 2012

Checking Programatically, if Document Library Folder is Hidden

SPFolder doesn't expose any direct property which can be used to analyze if the folder is hidden.

I got stuck into this and could get any solution from Internet also. So decided to write this blog post.

At some places, people are talking about analyzing SPFolder.Properties.Count which should be equal to 21 if the folder is visible. Unfortunately, that's not true !

While looking at SPFolder properties for a hidden folder, I came across 'Item' property (SPListItem type).

For hidden folders, this property was Null regardless of the content in that folder.

For visible folder, it was either 0 or greater than 0 but was not Null even if folder is empty.

So in my view, you should always use 'Item' property of SPFolder to analyze its visibility as follows:

If(SPFolderObj.Item == Null)

//This folder is hidden

Else

//This folder is Visible

Tuesday, April 17, 2012

Error on opening _layouts/ChangeSiteMasterPage.aspx

You created a custom master page in SharePoint designer 2010 and now want to apply it on subsites. What you will do?
One way is that directly navigate to http://server_name/subsite_name/_layouts/ChangeSiteMasterPage.aspx and change the master page.

Now, here is the problem !
If you haven't activated 'SharePoint Server Publishing Infrastructure', you will get an error screen (may be without giving you any details about error excepting the correlation Id !)

To activate 'SharePoint Server Publishing Infrastructure' feature, follow steps given below :
1. Navigate to 'Site Settings' of site collection
2. Click 'Site Collection Features' (in the secton 'Site Collection Administration')
3. Activate the 'SharePoint Server Publishing Infrastructure' feature.

Good luck!

 

Monday, April 16, 2012

New line in XPath expression in SharePoint Designer

Recently, while designing Data View Web Part with the help of SharePoint designer I had to concatenate two fields value with a line feed between them.

BTW, it has been my painful experience of putting a line feed in XPath expression.

After a lots of research I found that you can put '
'. So if you have to give a line break between two fields values then your expression would be something like this:
{@field1,'
', @field2}

For detailed solution, refer this link : http://www.infopathdev.com/forums/t/2013.aspx

Thursday, April 12, 2012

Weather RSS feeds : Which one to choose?

Yahoo
Google
Weather channel
WeatherZone
..and the list goes on!

In my view, Yahoo weather feeds are the best one (powered by Wheather Channel) and provide fastest updates. But wait ! You can not use them for commerical purpose. See their Terms of use here : http://developer.yahoo.com/weather/

Google weather APIs are used for iGoogle and are private to them. So can't use!

Weather channel is the paid one.

WeatherZone can be the best choice although provide updates later then Yahoo. But you can use them on your website (not mentioning any non-commercial/non-profit like stuff). You can see their terms of use on this link : http://www.weatherzone.com.au/services/rss.jsp

If you have any weather API/feed please share its detail here.

System.Net.WebPermission error in deploying a sandbox solution

You have deployed you sandbox solution successfully. And you see this permission error while inserting your web part:
Request for the permission of the type 'System.Net.WebPermission, System, Version 2.0.0.0, Culture-neutral, PublicKeyToken=b77a5c561934e089' failed.

It means that your sandbox solution is trying to access some resources which are not permitted.

Simply, change your Sandbox solution to Farm solution (steps given below) and probably, the error would disappear.

Convert Sandbox solution to Farm solution:
  • Click your project
  • Press F4 (or go to project properties)
  • Change Sandbox Solution to False.