Jan 3, 2012

How to Remove “+ Add document" from a SharePoint 2010 Document Library

In previous article, we have learned how to hide the Select/ Deselect Check Box from a view in the list/libraries.
In this post, we will see how to remove the + Add document” option from the document library in SharePoint 2010.
We will get some scenarios where, we will display the document library I different view and in that, we don’t want this option to be shown to the users. Because, it will allow the users to upload the documents.
Suppose the below is the document library where we want to hide the Add document option
 
We can achieve this by the following methods
1.   Editing the WebPart
2.   Using SharePoint Designer(CSS)
3.   Using J Query
4.   By Permission level(Default)

1. Editing the WebPart
Go to Edit WebPart -> Tool bar Type -> Select NoToolBar option which will hide the Add Document option
2. Using SharePoint Designer(CSS)
Go to the designer and edit the page/webpart where you want to hide. Search for class=”ms-addnew” and change the style to Style=”display:none”
3. Using J Query
Add a CEWP and link the following J-Query in it and hide the CEWP webpart
$(document).ready(function()
{
$(‘#WebPartWPQ2 .ms-addnew’).hide();
});
4. By Permission Level (Default)
We can set the permission level for the document library to read only and hence the user with read only option in the SharePoint site will not see this option
We will get the following result

Jan 1, 2012

How to hide the Select and Deselect Check box in a List/Library in SharePoint 2010

We might have faced some situations where you want to hide the Select and Deselect Option Check Box in the SharePoint 2010.
This is required, when you create some views and want to display some items with out check box options.
Let’s discuss about this in this article.
Suppose this is the document library where I want to hide the checkbox

Go to the Modify view in the Ribbon
You will see all the options for customizing the list\library. Click On the Tabular View.
Here you will find that, “Allow Individual Item Checkboxes” option is selected.
Unselect the Check Box and you are done. Now, you won’t see the Check Boxes in the list\Library as shown below
We can do this in SharePoint Designer also.
Go to the List/Library and then to the view where you want to hide the checkbox. Find the below section (.ms-WPHeaderTdSelection) and make this property to display equal to none.

.ms-WPHeaderTdSelection
{
Display:none;
}
That’s it. We have learned to hide the checkbox in lists and libraries of SharePoint 2010 using default settings and also using SharePoint designer 2010.

Dec 27, 2011

How to create a Tab using the labels in the blogger

In the previous article, we have discussed about increasing the traffic or the number of users to the blog. In this article, we will discuss how to create a tab using the labels which you have created for the posts in your blog.

If you have the older version of the blog, then in the design mode you will see an option for “Try the Updated Blogger Interface” and click to update to the new interface as shown below.

Don’t worry, at any time you can switch back to the older interface.
After updating to the new interface, go to the design and you will see a right navigation bar. In that, select Pages as shown below.
Once you click Pages, you will get a popup window allows you to create a blank page and the other is web address as shown below.
We will select web Address, as we are going to create a tab using the existing label URL.
When you click the Web address (as shown in the above figure), you will re-direct to popup window, where you can enter the Tab title and the Label URL.
Now, save the Web Address.
That’s it. Now, we will see a tab with the particular label which will show all the posts in the label.
Happy Blogging! 

Dec 26, 2011

How to hide the download a copy option (Context Menu) in the Document Library

In the document library we have an option of downloading the document as shown below.

If the user wants to hides or remove this option for all the users. The following steps will explain the same.
1. First locate the following path C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
2. Find the file named “CORE.js”. This is the file which will run the scripts downloading option for the document library.
3. Open the core.js file in best .js file editor and search for the function 
        AddSendSubMenu(m,ctx)
        Where you can see
        menuOption=CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
        menuOption.id="ID_DownloadACopy";
These lines of code which will display text "Download A Copy" and call the menu operation.
So, comment the code and save the file.
4. Now when you search the context menu (Download a copy) option will be hidden as shown in the following figure.

Disadvantage
The above solution will affect all the document libraries of the SharePoint Server.
So, how to do it a particular document library or one web collection?
Hence the solution is as follows:
1. Open the default.master page in the designer.
2. Locate the core.js in the master page
<SharePoint:ScriptLink language="javascript" name="core.js"                  Defer="true" runat="server"/>
3.   So we can create our own (with the modifications as shown above) .js file (example named customcore.js) and save it in the following location
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
4.   Now we can add the reference as shown below.
<SharePoint:ScriptLink language="javascript" name="customcore.js" Defer="true" runat="server"/>
5.   Now it won’t affect all the document libraries in the SharePoint server.

Bingo. We are done. We have restricted users to download the documents from the SharePoint Document library.


How to hide the left navigation bar in the SharePoint

In this article, we will see how to hide the left navigation in SharePoint siteThere are many ways for hiding the left navigation in the SharePoint. Here is the simplest way to hide it.
1.   Master.FindControl("PlaceHolderLeftNavBar").Visible = false;
2.   Place a content editor in the page you want to hide the left navigation pane in the site and add the following code in the source editor which will hide the left navigation bar.

<style>
.ms-navframe
{
display:none;
}
</style>
That’s it. We have easily hide the left navigation bar with a simple code.

How to increase the Traffic or the Users to a Blog

Hi All,
We will start discussing about the blogger tips also.
In this article, we are going to discuss how to increase the traffic to your blog. I have listed it below.
1. Design the UI properly – Branding
     The Look and feel is very important for a blog. This is the first thing which attracts the users to visit your blog often. So, plan the design and use proper templates or themes which suites your content.
2. Provide easy navigation for the users
      The navigation is very important, which makes the readers to navigate easily
without any difficulties. The readers must able to navigate to different pages and posts with the proper navigation techniques provide by you.
3. Write well and often
      The Number of more posts in your blog will increase the number of users and also the search engines will easily crawl and navigate the users to your blog. Also, write clearly and give the content which is new and useful to the readers.
4. Add Images for clear understanding
       If your want to impress the readers and also want the readers to understand the content easily, you can give the explanations by inserting some images in between. This makes the readers to understand the situation you are explaining in the real time.
5. Submit your blog to search engines
       Initially, your blog may/may not appear in the search engine. Go to the search engine and type your blog name which allows the search engine to know that there is a blog with this name and to crawl it. Once your blog becomes popular, search engines automatically find your blog posts.
6. Adding links of the other sites
       This is one of the ways, which makes your blog popular. By adding the references to the other sites, you are allowing the user to navigate to the other sites which will increase the traffic to your blog. If you are referring for some other useful information from different sites, always create a link for that word or site which is a good way to write blog.
7. Allow reader comments and thoughts
       Allow the readers to comment and share their thoughts. This will make the blog popular. You will come to know, how the users are made helpful through your blog. You can reply to them, if they are struck up with any doubts.
8. Use links in between and trackback URL’s
       Always, create a links in between the posts. If you are writing a post, which is related to some previous posts, then you can make the readers to read the previous articles by giving a link. This makes the readers to know the other articles in your blog.
9.  Proper Titles and keywords
      This is very important for a blog which indeed increase your blog traffic in the search engines. Always, use proper title which is appropriate to the content. This will make the readers to know the theme of the article before they start reading it.
10.  Syndicate your blog’s content with RSS feed
       Sign up with the RSS feeds and allow your blog contents to burn through the feeder. Give the options like Subscribe through the RSS feeds which will allow the readers to know the new article published in your blog and in turn allows the user to visit the blog more frequently.
11.  Submit your posts to social network site
       The social networking is one of the popular media in the internet which allows the users to connect and share. Hence, submit your posts to the social networking sites.
12.  Fulfill the user’s request
        If a reader is unable to achieve the idea or solution is given by you, then you can guide them properly which will always makes the readers, a user-friendly site.
13.  Invite people to view your blog through e-mails
        If a new article is published, then you invite the readers to view the articles and hence increasing the user re-views more.
14.  Properly tag and categorize the contents
        Always, tag the articles and categorize it properly. If a reader is in need of articled of same type (tagged contents), then through the tags, they can easily navigate and read the articles.
15. Create a page or account in the social networking sites
        Create a page or account in the social networking sites and feed the posts which will allow the users from the social networking sites to view the blog.

I gave a small explanation for increasing the traffic to the blog and hope this helps in increasing the traffic to your blog.

Happy Blogging!

Dec 23, 2011

Programmatically Creating Site Backup in SharePoint

In the previous article, we have discussed about creating and restoring the SharePoint site using stsadm command.
In this article, we will see how to take the backup of the site using SharePoint Object Model.The below is the code that will create the backup of the site and log the information in a log file.
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace SiteBackUp
{
    public class SiteBackup
    {
        static void Main(string[] args)
        {
         siteBackup("http://servername:portnumber","SharePointSiteBackup");   
        }
        public static void siteBackup(string siteURL,string fileName)
        {
            try 
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using(SPSite objSite=new SPSite(siteURL))
                    {
                        using(SPWeb objWeb=objSite.OpenWeb())
                        {
                            bool currentSiteStatus=objSite.AllowUnsafeUpdates;
                            objSite.AllowUnsafeUpdates=true;
                            bool currentWebStatus=objWeb.AllowUnsafeUpdates;
                            objWeb.AllowUnsafeUpdates=true;
                            string comment = objWeb.Title+"- Creating Backup is completed";
                            SPSiteCollection siteCollection=objSite.WebApplication.Sites;
                            objSite.ReadOnly=true;
                            string time=DateTime.Now.ToString("dd-MM-yyyy");
                            string backupName= "D:\\SiteBackup\\Backup" + fileName+"_"+time+".bak";
                            siteCollection.Backup(siteURL,backupName,false);
                            objSite.AllowUnsafeUpdates=currentSiteStatus;
                            objWeb.AllowUnsafeUpdates=currentWebStatus;
                            if(objSite.ReadOnly==true)
                            {
                               objSite.ReadOnly=false;
                               siteBackupLog(comment);
                            }                        
                         }
                    }
                });
            }
            catch (Exception ex)
            {
                SPSite site = new SPSite(siteURL);
                if (site.ReadOnly == true)
                    site.ReadOnly = false;
                siteBackupLog(ex.Message);
            }
        }
        public static void siteBackupLog(string message)
        {
            string PathName = "C:\\SiteBackup logs\\";
            PathName = PathName + "Backuplog-" + DateTime.Now.ToString("dd-MM-yyyy") + ".log";
            StreamWriter sw = new StreamWriter(PathName, true);
            sw.WriteLine(message + " - " + DateTime.Now);
            sw.Flush();
            sw.Close();
        }
    }
}

Hence, we can automate creating backup of the SharePoint site using code. Also, the whole code created in visual studio can be downloaded here.
Happy Coding!

stsadm Command for Creating Backup and Restoring a Site in SharePoint

In this article, we will discuss how to take a backup and restore it using the stsadmn command in SharePoint (WSS 3.0, MOSS 2007).
In SharePoint 2010, we use Power Shell instead of this command.
Before going for that let’s discuss about stsadm
What is stsadm command?
It is a command line tool for administration of SharePoint sites.
Where it is located in the server?

Normally, it is present in the following path

C:\ProgramFiles\Common Files\Microsoft Shared\Web Server Extensions\12\Bin

When you are in the Admin groups, you will able to use this command and perform all the functions.
Site Backup & Site Restore:
Navigate to the following path in command prompt first
C:\>cd Program Files\Common Files\Microsoft Shared\web server extensions\12\bin

1. C:\ Program Files\Common Files\Microsoft Shared\web server extensions\12\bin>stsadm.exe –o backup –url “Site URL” –filename “Location of DAT file with extension” -overwrite
2. C:\ Program Files\Common Files\Microsoft Shared\web server extensions\12\bin>stsadm.exe –o restore –url “Site URL” –filename “Location of DAT file with extension” –overwrite

Example:
Location of DAT file with extension – D:\FolderName\FileBackup.dat