Thursday, August 23, 2012

Hide buttons control from ribbon for specific list

Hi ,

I want to hide "New Folder" button from ribbon of my library "Shared Documents" for site "SP2010-01".

 
 

To hide this button from ribbon for a Shared Documents, You must write this code :

using (SPSite site = new SPSite("http://SP2010-01"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists.TryGetList("Shared Documents");
web.AllowUnsafeUpdates = true;
SPUserCustomAction actionView = list.UserCustomActions.Add();

StringBuilder newurl = new StringBuilder();
newurl.AppendLine("<CommandUIExtension>");
newurl.AppendLine("     <CommandUIDefinitions>");
//Provide Location ID to hide the button
newurl.AppendLine("        <CommandUIDefinition Location=\"Ribbon.Documents.New.NewFolder\">");
newurl.AppendLine("        </CommandUIDefinition>");
newurl.AppendLine("    </CommandUIDefinitions>");
newurl.AppendLine("</CommandUIExtension>");

actionView.Location = "CommandUI.Ribbon";
actionView.Title = "RemoveNewFolderButton";
actionView.CommandUIExtension = newurl.ToString();
actionView.Update();

web.AllowUnsafeUpdates = true;
}


After deployment of this code, you will see :

 
 

This code will hide "New Folder" button from "Shared Documents" library from "SP2010-01" site.

For more location ID visit site.

Enjoy!!!

Tuesday, August 21, 2012

DateTimeControl is not showing it’s calendar in proper format


Hi,

Some time we have to create our own customized asp form or visual web part or simple web parts where we use SharePoint’s Date Time Control . Some time that control works properly but some time this control does not show calendar in proper format as we see in SharePoint. Control should show calendar like :
















But instead of the format, It shows like this :


















If you want to change this format for default format you have to write this code:

dateTimeControl1.DatePickerFrameUrl=ResoulveRul(SPContext.Current.Site.Url+”/_layouts/iframe.aspx”);

Saturday, August 18, 2012

Make Read Only or Hide Fields in SharePoint 2010

Hi ,

If you want to make field as read only or hide fields , you must read this article. It is too good. Just download files & install as instructed.

To read full article : SPUtility

To read documents : Documents

To download code files : Download