Dec 14, 2011

Dec 12, 2011

SlideShow with Thumbnails using Silverlight for SharePoint

I would like to share a link which shows how to create a Slide Show for SharePoint using Silverlight in Microsoft Visual Studio 2010.


Embedding YouTube Videos to the SharePoint Site

Steps
1.  Go to the YouTube site and navigate to the video which you like to embed in the SharePoint Application.
2.  Click on Share button below the video as shown below


3. On clicking Share you will find two options as Mail or Embed as shown below
 


4.  Copy the code from the Embed option as show above and save it in a notepad. I named it as youtubetest.txt
Code example in my case
<iframe width="560" height="315" src="http://www.youtube.com/embed/6986O9VA6LU" frameborder="0" allowfullscreen></iframe>
5. Upload the text file to SharePoint Document Library and right click on the file and
copy the shortcut from it.
6.  Now go to the SharePoint page where you like to add the YouTube video and edit 
the page.
7. Click insert a web part -> add a Content Editor web part 
8. Edit the web part and now add the shortcut of the youtubetest.txt path in the Content Link property of the web part or you can directly add the code which is copied from the YouTube site in the Source Editor property of the web part and save it.
You will get the following result.


You can place this web part in the Home Page of your SharePoint site.
Enjoy!

Dec 11, 2011

Reading Custom Properties of Word Document

Part III
Read the Introduction about this article Part I
Read about reading the summary properties of word document in this article Part II
In this post, we can see what is the code for the reading the custom properties of the word document.
public static void GetDocumentCustomProperties(string filename)
{
            OleDocumentPropertiesClass doc = new OleDocumentPropertiesClass();
            doc.Open(filename, true, dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
            //Reading and writing the custom properties to a file
            StreamWriter sw1= new StreamWriter(@"D:\FileRead_Custom.txt");
            CustomProperties obj_CustomProp = doc.CustomProperties;
            foreach (CustomProperty custom_prop in obj_CustomProp )
            {
                sw1.WriteLine(custom_prop.Name   "    "   custom_prop.get_Value());
            }
            sw1.Close();
            doc.Close(false);
}
Hope this helps you!

Reading Summary Properties of Word Document

Part II
Read the Introduction about this article Part I
In this post, we can see what is the code for the reading the summary properties of the word document.
public static void GetDocumentSummaryProperties(string filename)
{
            DSOFile.OleDocumentPropertiesClass doc = new DSOFile.
            OleDocumentPropertiesClass();
            doc.Open(filename, false,

            DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess );

            //getting the properties of the document
            DSOFile.SummaryProperties summaryProp = doc.SummaryProperties;

            //reading and writng the summary properties to a file
            string author = summaryProp.Author;
            string comapanyName = summaryProp.Company;
            string managerName = summaryProp.Manager;
            StreamWriter sw = new StreamWriter(@&quot;D:\FileRead.txt&quot;);
            sw.WriteLine(author);
            sw.WriteLine(comapanyName);
            sw.WriteLine(managerName);
            sw.Close();
}
That’s It. Enjoy Happy Coding!
Also, read how to Read the Custom Properties of Word Document Part III

Reading Document Properties

Part I
We are going to discuss about a interesting topic which can be used in SharePoint and also in .Net.
It is possible to reading the summary properties and custom properties of the word document and it is also one of the requirements now a days.
This can be done through using DSO dll which can be downloaded from the below link
(Important Note: This is a 32 bit dll )

What is DSO dll ?
The Dsofile.dll sample file is an in-process ActiveX component for programmers that use Microsoft Visual Basic .NET or the Microsoft .NET Framework. You can use this in your custom applications to read and to edit the OLE document properties that are associated with Microsoft Office files, such as the following: 
• Microsoft Excel workbooks
• Microsoft PowerPoint presentations
• Microsoft Word documents
• Microsoft Project projects
• Microsoft Visio drawings
• Other files that are saved in the OLE Structured Storage format
The Dsofile.dll sample file is written in Microsoft Visual C++. The Dsofile.dll sample file demonstrates how to use the OLE32 IPropertyStorage interface to access the extended properties of OLE structured storage files.
Features of this DLL
1. This dll is 32 bit and can read only Microsoft word 2003 (ie., .doc) formats only.
2. It has a OLE property reader class which can read the properties of the word document.
3. Using this dll, we can read both the Summary properties and also the Custom properties we create for the documents.
4. Also with this dll, we can set the custom properties programmatically.

Also, Read how to extract the summary properties of the word document in this article Part II.

Twitter WebPart for SharePoint

I have already posted a link which will guide you in creating the twitter and Face book web parts for SharePoint in this article. Twitter and FaceBook for SharePoint. Have a look at this.
Yet another easiest way for twitter is as follows:
Steps:
1. Open the site page where you want to add the twitter widgets.
2. Add a Content Editor Web part.
3. Now open this URL in your browser
4. You will find 4 widgets (in the Widgets for my site option) which is provided by default in the Twitter Official Site
·                      Profile Widget
·                     Search Widget
·                     Faves Widget
·                     List Widget
5. All the information about the widgets will be given the site.
6. Now for example I will add the SEARCH WIDGET to our site. I click on Search Widget which will navigate to this link
7. You have 4 options such as Settings, Preferences, Appearance and Dimensions.
8. Here you can customize everything and my sample is shown code grabbed from the site is shown below.
<script src="http://widgets.twimg.com/j/2/widget.js">
</script>
<script>
new TWTR.Widget({
  version: 2,
  type: 'search',
  search: 'SharePoint',
  interval: 30000,
  title: 'What people are saying about',
  subject: 'SharePoint',
  width: 250,
  height: 300,
  theme: {
    shell: {
      background: '#8ec1da',
      color: '#ffffff'
    },
    tweets: {
      background: '#ffffff',
      color: '#444444',
      links: '#1985b5'
    }
  },
  features: {
    scrollbar: false,
    loop: true,
    live: true,
    hashtags: true,
    timestamp: true,
    avatars: true,
    toptweets: true,
    behavior: 'default'
  }
}).render().start();
</script>

9. That’s it!! Add this code in the Source Editor of the Content Editor Web Part.
10. This will display all the tweets with respect to the Query you gave in the Search. The webpart will look like this.


11. Save it!! Enjoy the Twitter integration in your SharePoint Site.

RSS Feeds WebPart

In this post we will see how to create RSS feeds web part for SharePoint. it is very easy and we will learn it in the following steps.
1. Add a XML web part to a share point page where you want to add the RSS Feeds web part.
2. Edit the properties of the web part.
3. In the XSL editor place the code (given below).
4. In the XML link give the proper RSS feeds URL.
5. Click Save.
6. This will display the RSS feeds from the URL linked in the web part.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<div>
<xsl:apply-templates select="rss/channel"/>
</div>
</xsl:template>
<xsl:template match="rss/channel">
<xsl:variable name="link" select="link"/>
<xsl:variable name="description" select="description"/>
<ul><xsl:apply-templates select="item"/></ul>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="item_link" select="link"/>
<xsl:variable name="item_title" select="description"/>
<xsl:if test="position() &lt; 6">
<li>
 <a href="{$item_link}" title="{$item_title}"><xsl:value-of select="title"/></a>
 </li>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

Copying the File from and to Document Library in SharePoint

Let’s see how to copy the file from and to the document library using object model.
SPSite site = new site("http://siteurl");
using (site)
{
    SPWeb web = site.OpenWeb();
    using (web)
    {
        SPList lib1 = (SPDocumentLibrary)web.Lists["lib1"];
        SPList lib2 = (SPDocumentLibrary)web.Lists["lib2"];
        SPListItem item1 = lib1.Items[0];
        byte[] fileBytes = item1.File.OpenBinary();
        string destUrl = lib2.RootFolder.Url   "/"   item1.File.Name;
        SPFile destFile = lib2.RootFolder.Files.Add(destUrl, fileBytes, true);
    }
}

That’s it! Happy coding!

Displaying Multiple Document Libraries in a Single WebPart

A frequent requirement in the Share Point Projects is Displaying Multiple Libraries together in a single web part. It can be achieved by various methods but I am going to create it through Share Point Designer 2007.
In this article we will come to know how it can be done step by step.

1. The Important thing here to be noted is, whatever may be the number of Document Library going to be merged here, and it should contain the same number of columns and name.
2. If not, this web part won’t work.
3. Create two document libraries (Example : Test1,Test 2)
4. I have created 4 columns such as Type, Title, Name, and Created by in both document libraries.
5. Now, we are going to use the designer 2007 here to proceed.
6. Open the site in designer –> create an .aspx page.
7. In the right side of the designer -> go to Data Source Library -> Linked Sources
8. In the Linked Sources click -> create a New Linked Source.
9. We have Three Tabs here ,
General
a. In General -> Give the Name of the web part
b. In Description-> Give  the Description of your web part
c. In Key Words -> Give the Keywords if u like
Source
a. Click Configure Linked Source -> Pop up window will Show all the  Available Data Sources  as shown below
b. Under the SharePoint Libraries -> add the two document libraries created (Test1,Test 2)
c. Click Next Button


d. Leave the default option (Merger the contents of the data sources….)
e. Click Finish and it show it as shown below.
f. Click ok.
10. Now open the page where you want to add the web part in the designer. Then click “Click to insert a web part” option in the page.
11. In the Data Source Library under Linked Sources you will see the created (here I gave it as Multiple Document Libraries in Single List) the linked source as shown below.

12. Click on the Drop Down in the created Linked Source and click Show Data which will show the “Data Source Details” as shown below.
13. You will see all the columns present in the Document Libraries.
14. Press CTRL and select the columns which you want to display in the Web Part.
15. Then Click on the Insert Selected Fields as…  -> Select Multiple Item View
16. I have selected Name for Use in Forms, Created by and Path from the columns and inserted it in the site which is as follows.
17. We have to format this view so that it looks good to view.
a. First Column is formatted so that select the Format as with Label
b. Then second column  created by in the same way select Format as with Label
c. Finally third column select Format as with hyperlink and give the following the pop-up window.
     Address: /{@FileDirRef}
     Label: {@FileDirRef}
18. We have completed creating the web part. Finally it will look as shown below.


So we are now able to list and view the documents from two document libraries as shown below !!!

Dec 9, 2011

Recommendations for maintaining Infopath performance

I'm creating an InfoPath form that is a bit large and starting to lag so I decided to look up better practices for developing InfoPath forms to maintain performance. Here is what I found online:
- Keep views from being too large or complex. Split large views into several smaller ones with buttons to switch between them.
- Avoid lots of tables (data or layout) in any single view.
- Use Master/Detail to reduce the number of controls in one page, whenever possible.
- Try to use filter to filter the table rows (instead of conditional
formatting).
- Avoid large repeating data structures that can grow to many pages.
-Avoid complex nesting of optional and repeatable sections. These are quite complicated to layout and also can quickly cause a single view to become very large.
- Avoid using Percentage width for your controls if your view contains lots of nested controls. We have seen over 50% improvements by using Fixed Width. You can apply specify a fixed width in the control's properties dialog.
- Be aware of exactly what your business logic does. For example, onAfterChange can fire multiple times for a single edit.
- Rather than querying for all the data then having InfoPath just show a small amount, refine your query and only bring the data you plan on displaying into InfoPath.
- Only get the data you need to load the form. Don't pre-populate data sources that aren't necessary on load.
- Merge static xml data sources into one if you have multiple xml data connections.
- Use Expression Box to display calculated value if you don't need to store the value. If you have business logic to trigger all the calculation, only trigger necessary calculation. Triggering large amount of calculations is costly.
- When using digital signatures, only digitally sign the information you need to. Signing takes a screenshot of the data signed and encodes it in the form. The larger the screenshot, the larger the xml will become with the encoded image.
- Avoid attaching large files to the form. These files are encoded in the xml and can cause issues if they become too large. Provide links over embedding large files if possible.
- Avoid embedding images in a form. For the same reasons as above.

SharePoint Designer opens in contributor mode

We may face some situation, while editing the site using Sharepoint Designer, it will get open in Contributor mode and we will not be able to edit the site, eventhough we have the Site Collection Administrator(SCA) permission.
 By default, Contribute permissions are assigned to the Site Collection Members  group. Even though, we are part of SCA group, if we are member of Site Collection members the Designer will open in Contributor mode.
To overcome this just disable the contributor settings in SharePoint designer by using the below steps:
1. Open the site in SharePoint Designer.
2. Select the Site Tab -> Contributor Settings.
3. Click on Disable Contributor settings button.
Now we will be able to edit the site.

How to convert Infopath form to word document

Sometimes you may need to convert an InfoPath form into a Word document so you can send it to users that either don’t have InfoPath or can’t access your  SharePoint form library. Luckily there is an easy process to do so.
Steps to convert InfoPath form to Word:
1) Open your .xsn InfoPath project file
2) Go to File -> Export To -> Web
3) Enter a name for the file and make sure “Single File Web Page (*.mht;*.mhtml)” for Save as type is selected. Click Export
4) Locate your new .mht file and open it with Word.
5) You should see your InfoPath form in Word. You may have to adjust any checkboxes or radio buttons that may be on the form. Make sure to save the file as a .doc or .docx file type when you’re done

Integrating Twitter and FaceBook in SharePoint

I would like to share the link which is very simple and clear way of integrating the twitter and facebook in SharePoint.

Twitter Integration


Face Book Integration



Nov 24, 2011

Checking whether a file uploaded is of .doc or .docx file format

We can use the Java Script to check whether the file uploaded is of 2003 or 2007 word format. Hence we can handle the validation in the client side.
Java Script
<script type="text/javascript" language="javascript">
   function FileFormatValidate()
   {
        var uploadControl = document.getElementById('<%=FileUpload1.ClientID%>').value;
        //Regular Expression for the fileupload control.
        var reg = /^(([a-zA-Z]:)|(file://%7b2%7d/w )/$?)(//(/w[/w].*)) (.doc|.docx|.DOC|.DOCX)$/;
        //Checking if the file is empty or not
        if (uploadControl.length > 0) 
        {
            //Checks with the control value.
            if (reg.test(uploadControl)) 
            {
                return true;
            }
           else 
            {
                //If the condition not satisfied shows error message.
                alert("Only .doc, docx files are allowed!");
                return false;
            }
         }
        else 
        {
            //If the File is Empty or No File is  selected to upload shows this 
error message.
            alert("Please select a file to Upload");
            return false;
        }
    } //End of function FileFormatValidate.
</script>
Design
<p style="height: 28px; width: 216px">
    <asp:Button ID="btn_Upload" runat="server" Height="25px" 
        onclick="btn_Upload_Click" OnClientClick="return FileFormatValidate();" Text="Upload" Width="128px" />
</p>

Hence you can validate and check the file being uploaded at the client side using this code. This can be re-used for any file formats by changing the Regular Expression.
Happy Coding!!!


List of SharePoint 2010 Web Parts

Authoring
 Content Editor 
 Image Viewer
 Media Web Part
 Page Viewer 
 Silverlight Web Part
Business Data
 Business Data Actions
 Business Data Catalog Filter
 Business Data Item
 Business Data Item Builder
 Business Data List
 Business Data Related List
 Key Performance Indicators
 KPI Details
 Visio Graphics Service 
Content Rollup
 Chart Viewer
 Content Query
 HTML Form Web Part - Foundation
 Picture Library Slideshow Web Part
 RSS Viewer
 XML Viewer
 What’s Popular
Documents
 Document ID Lookup
 Document Set Contents
 Document Set Properties
 Relevant Documents
Filters
 Choice Filter
 Current User Filter
 Date Filter
 Filter Actions
 Page Field Filter
 Query String URL) Filter
 SharePoint List Filter
 SQL Server Analysis Services Filter
 Text Filter
My Information My Calendar
 My Contacts
 My Inbox
 My Mail Folder
 My Tasks
Navigation
 Categories
 Site Aggregator
 Sites in Category
 Summary Links
 Table of Contents
 Tag Cloud
Office Client Applications Excel Web Access
 InfoPath Form Web Part
 WSRP Viewer
People
 Contact Details
 Profile Browser
 Site Users - Foundation
 User Tasks - Foundation
PerformancePoint
 PerformancePoint Filter
 PerformancePoint Report
 PerformancePoint Scorecard
 PerformancePoint Stack Selector
Search Advanced Search Box
 Dual Chinese Search
 Featured Content
 Federated Results
 People Refinement Panel
 People Search Box
 People Search Core Results
 Refinement Panel
 Related Queries
 Search Action Links
 Search Best Bets
 Search Box
 Search Core Results
 Search Paging
 Search Statistics
 Search Summary
 Top Federated Results

Deafult.aspx is not opening in the SharePoint Designer

PROBLEM: Deafult.aspx is not opening in the SharePoint Designer


Error Details   

     Soap: Server was unable to process request. A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered as safe on this site. You may not be able to open this page in an HTML editor that is compatible with Microsoft Windows SharePoint Services, such as Microsoft Office SharePoint Designer. To fix this page, contact the site administrator to have the Web Part or Web Form Control configured as safe. You can also remove the Web Part or Web Form Control from the page by using the Web Parts Maintenance Page. If you have the necessary permissions, you can use this page to disable Web Parts temporarily or remove personal settings. For more information, contact your site administrator.


Solution       

The problem is that the default.aspx page may contain some error web parts which can be removed by hitting the following url


This will open the web part maintenance page. So, here you can delete the error web part.


What is 12 and 60 Hive in SharePoint ?

You'll hear SharePoint people talk about and refer to the "12 Hive" or the "60 Hive" regularly. We don't know what it is and we use it .

The "Hive" concept was coined by Todd Bleeker. So what does it mean?
12 Hive is the location where MOSS 2007 and WSS 3.0 install their files on the file system. 
The same thing applies to 60 Hive which, as you may guess is the location of SPS 2003 and WSS 2.0 files. 

Locations:
12 Hive C:\Program Files\Common Files\Microsoft Shared\web server extensions\12
60 Hive C:\Program Files\Common Files\Microsoft Shared\web server extensions\60

Migration of WSS 3.0 to SharePoint Server 2010

I have some ideas grabbed from the internet regarding the migration of WSS 3.0 to SP 2010 server. My thoughts are as follows.
1. WSS 3.0 (with SP2) can be migrated to SharePoint Foundation 2010 directly.
2. The migration of WSS 3.0 (with SP2) to SharePoint Server 2010 is possible by attaching DB upgrade only. The direct migration is not possible.
3. But the WSS 3.0 (with SP2) can be migrated to MOSS 2007 first then to SP Server 2010
Ref: http://technet.microsoft.com/en-us/library/cc262747.aspx


SharePoint Designer opens in Contributor mode.

We may face some situation, while editing the site using Sharepoint Designer, it will get open in Contributor mode and we will not be able to edit the site, eventhough we have the Site Collection Administrator (SCA) permission.


By default, Contribute permissions are assigned to the Site Collection Members group. Even though we are part of SCA group, if we are member of Site Collection members the Designer will open in Contributor mode.


To overcome this just disable the contributor settings in SharePoint designer by using the below steps:

1. Open the site in SharePoint Designer.

2. Select the Site Tab -> Contributor Settings.

3. Click on Disable Contributor settings button.


Now we will be able to edit the site.


Nov 20, 2011