Compare Content Types in SharePoint List


Did you try to get a content type attached to list by its Id? for example you need to add a condition if a list item is Folder content type

I tried, it was simple but tricky because it seems to have a new ID inherited from the original content type so you must get the item content type first then compare its Parent with the Content type you need.

Here is an example to know if the current item is Folder content type or not (Folder content type has Id = 0x0120) :

If you use the following code it will give false although the content type is folder type

item.ContentType.Id == new SPContentTypeId(“0x0120”)

you have to use the following code to make it work

item.ContentType.Id.Parent == new SPContentTypeId(“0x0120”)


Create People Search Page on Your SharePoint Web


SharePoint 2010 provide a people search as an out of box feature but you will not find a people search result page on your created site. You must create a new site collection based on Search Center template to find this page.

My problem was I need  people search results page on my current site to avoid redirect the user  to another site collection

The solution was so simple:

1 – Activate the ShrarePoint Server Enterprise Site Collection feature found on the site features

2 – Add People Search Core Results Web Part found in search category

3- Add a text box and button to redirect to this page with query string “k” which take the value of the your search ex(?k=Mohamed)

Get a Localized String From SharePoint Application Resources


At the begging of any SharePoint I used to configure our project to deploy a resources files to APP_GlobalResources folder of our application virtual directory used by IIS.

You can’t simply do this using visual studio. You can do a lot of workarounds to make this work for you because visual studio don’t allow you to deploy resources files directly to APP_GlobalResources, it allows you only to deploy these files to application resources which found on 14 hive\Resources.

There is no problem where to deploy it but I have to add it to APP_GlobalResources to use it like the same way I use it in ASP.NET

Today I discover there is a smiple solution, I can use it directly from the 14 hive based on a SharePoint utility method called SPUtility.GetLocalizedString(), so I implement a method as following to do this:

public static string GetResource(string key, string resourceFileName)
return SPUtility.GetLocalizedString(“$Resources:”+key,resourceFileName,(uint)System.Threading.Thread.CurrentThread.CurrentUICulture.LCID);

Avoid “Show Unsecured Content” Message In HTTPS Sites


Hi All,

If you are developing a website which will be published in a secure socket layer (HTTPS) you may face some issues after publishing it for example a JavaScript may fall to run successfully and your web browser gives you a strange message tells you that this page contain unsecured content and give you the choice to view all content.

The problem here you added a reference to HTTP site in your page for example you use a JavaScript file which is hosted on an HTTP website

To avoid this problem you have to minimized depend on other websites as possible as you can

Find Control In ASP.NET Content Page


Hello everyone,

Have you ever tried to find an control using Page.FindControl() method in case that this page have a masterpage? if you answer is no, please try it and you will discover that this method won’t return any object, actually there is no direct way to make this.

Although the control is found in the page, ASP.NET consider that the control is located on the content placeholder control of the master page, so you have to get this control using the content place holder of the masterpage not the content control on the current page as following


Add Condition in Select Clause


For example you need to build a query which displays the username and if he administrator or not according to his role. you can use case statment like the following:
note:Assume admin user has the typeID = 1

From Users

Its syntax like the following:

SELECT CASE –Column Name–
WHEN –Value1– Then –Result1–
WHEN –Value2– Then –Result1–
WHEN –Value3– Then –Result1–
ELSE –Default Result–