Jan 5, 2012

Basics of Visual WebPart in Microsoft Visual Studio 2010

In this article, we are going to discuss about an interesting feature of Microsoft which is called Visual Webpart.
Web parts play an important role in the SharePoint design and development.
In the lower versions of SharePoint, we have to write the code for designing the webpart and then the custom code for its function.
But with the introduction of Visual Studio 2010 and SharePoint 2010 improved the way of creating and deploying the web parts in SharePoint (which is drag & drop the controls and design easily).
What is Visual Webpart?
In simple words, visual webpart is the wrapping the web user control (.ascx page) within a web part. 
Hence, the Web Part class will load a User Control in the Web Parts CreateChildControls() method and this user control is what you can drag and drop your controls to design the webpart. The Visual Studio interface nicely makes these operations seamless and takes care of all the wiring for deployment.
I will diagrammatically represent the visual web part


Advantages
1. Design of the web part is very easy, since it involves only drag and drop of the controls
2. No need to use the STSADM commands for adding an deploying the solution to the SharePoint site, since it involves only single click to deploy the solution
3. When we want to alter the design or change the code due to some bugs, we can make the changes-> re-build the solution-> deploy from the development environment which will automatically make the changes in the SharePoint site and even in the web part added in any of the pages
See also, how to create and deploy a Visual Web Part using Microsoft Visual Studio 2010 in this article.

See also, how to create a Visual Web Part and deploy the solution in SharePoint 2010 in this article.

Jan 4, 2012

Implementing Federated Search Result (Twitter) in SharePoint 2010

In the previous article, we have discussed about the basics of Federated Search Results in SharePoint
In this article, we will discuss how to implement the Federated Search results in SharePoint 2010.
Steps
Go to Central Administration of the SharePoint Server -> Application Management -> Manage service applications
You will see a list of services. In that Select Search Service Application

Clicking on this, you will be re-directed to the Search Server Administration page. In the left navigation, you will see some menus as shown below. Select Federated Results in the left navigation menu.
You will see a page, where you will find options for creating a New Location for Federated search or you can import the FLD file through Import Location option.

Clicking on the New Location option you will see the following page, where we will configure your Federated Location as shown below

That’s it. I have added the FLD file at the end of the article, for download so that you can download and import the file and work on it.
Now, we have configured the New Location and hence we will use the created Federated Location in the Search Center.
I have created a Search Center as shown below. First give a search query and in the results page, we will add the Twitter Results federated location.


In the search result page, edit the page and you will see options for adding the web part as shown below


After adding the Federated Results webpart, configure the results as shown below.

That’s it. We are done. Save the webpart and give a search keyword and test. You will be able to see the results from the intranet and from the internet search results (here Twitter).
You can download the Twitter FLD file from here.
Enjoy SharePoint using!

Jan 3, 2012

Federated Search Results in SharePoint

In this article, we are going to discuss about another interesting topic called Federated Search which came up with the MOSS (Microsoft Office SharePoint Server), when Microsoft updated the Infrastructure in SharePoint.

What is Federated Search?
Federate - Characterized by unity or being or joined into a single entity
Federation allows users to send the same query (search keyword) to multiple independent repositories, and display the results from each in its own region on a results page.

Advantages
1. It is helpful, when the search data is stored in the multiple repositories or to display results from various locations
2. We can bring the results from various social networking sites (Twitter, YouTube, Flickr etc.,) and search engines (Google, Bing, Yahoo, etc.,) easily in our search results page
3. Displaying the results from various sites and search engines allows the user to view the results from different source in a single page
4. We can display different types of results like Sites, Images, Videos, etc., This allows the users to interact with the site more easily.

Disadvantages
1.If we are using this federated search results in a corporate intranet, then there will be security issue. This is because, all the search queries/keyword (which may be confidential to a company) will be sent to the search engines. This search engines will store the data for some time, even after querying the results.
2. We cannot crawl the results from the other sources (Search Servers) and store the index
Hope this helps you!


Also, read about Configuring a Federated Results for Twitter in SharePoint 2010 and using it in this article.

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.