Wednesday, September 14, 2011

Friday, September 9, 2011

Show Quick Launch on SharePoint 2010 Custom Webpart Page

When you create a webpart page on SharePoint 2010 by default it will not have the quick launch will vanish.

All you needed to do is edit the page in SharePoint Designer and remove the following lines:


< asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server">
< asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server">




You also need to delete the following:

< style type="text/css">
body #s4-leftpanel {
display:none;
}
.s4-ca {
margin-left:0px;
}


Done. Now refresh the page and the quick launch will now display on the web part page.

Thursday, August 25, 2011

Get DLL Out of The GAC

DLLs once deployed in GAC (normally located at c:\windows\assembly) can’t be viewed or used as a normal DLL file. They can’t be directly referenced from VS project. Developers usually keep a copy of the original DLL file and refer to it in the project at development (design) time, which uses the assembly from GAC during run-time of the project.

During execution (run-time) if the assembly is found to be signed and deployed in GAC the CLR automatically picks up the assembly from the GAC instead of the DLL referenced during design time in VS. In case the developer has deleted the original DLL or don't have it for some reason, there is a way to get the DLL file from GAC. Follow the following steps to copy DLL from GAC
  1. Run regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\yourdllname.dll
  2. yourdllname.ddl is an explorer extension DLL that gives a distinct look to the GAC folder. Unregistering this file will remove the assembly cache viewer and the GAC folder will be then visible as any normal folder in explorer.
  3. Open “%windir%\assembly\GAC_MSIL”.
  4. Browse to your DLL folder into the deep to find your DLL.
  5. Copy the DLL somewhere on your hard disk and refer it from there in your project
  6. Run "regsvr32 /i %windir%\Microsoft.NET\Framework\<.NET version directory> \yourdllname.dll" to re-register the shfusion.dll file and regain the original distinct view of the GAC.

Thursday, August 11, 2011

Add / Upload document to Document Library using SharePoint Object Model

Below is the code to upload document to SharePoint Document Library with all the metadata you wanted to update.


String fileToUpload = @"C:\FileNamePath.txt";
String sharePointSite = "http://urSharePointsite.com/sites/";
String documentLibraryName = "Shared Documents";

using
(SPSite oSite = new SPSite(sharePointSite))
{
   using
(SPWeb oWeb = oSite.OpenWeb())
   {
        SPFolder myLibrary = oWeb.Folders[documentLibraryName];

        //upload document
        String fileName = System.IO.Path.GetFileName(fileToUpload);
        FileStream fileStream = File.OpenRead(fileToUpload);

        // Upload document
        SPFile spfile = myLibrary.Files.Add(fileName, fileStream, true);

        SPListItem spLibItem = spfile.Item;


        spLibItem["Title"] = "Document Title";
        spLibItem["Field2"] = "Field2 Value";
        spLibItem.Update();
     }
}




Fetch user details based on user Alias/ Display Name and Update it to People or Group Field in List


The UserID relates to the ID of the user within the site collection. This is fine but the chances are that not all users are members of the site collection. To address this, the SharePoint OM has a handy little method called SPWeb.EnsureUser() which accepts a Login Name of a user as a string and first checks if the user exists in the site collection, if it does not then it adds the user and returns an SPUser object. Please be aware that you may need to set SPWeb.AllowUnsafeUpdates = True for this to work.
From the SPUser object it is very simple to get the ID (SPUser.ID.ToString() and SPUser.LoginName.ToString()) and then use simple string building to get the string in the right format for the ‘Person or Group’ field.

string sAllContacts = "";

using (SPSite site = new SPSite(“http://sites/site/yoursite”))
{
    site.AllowUnsafeUpdates = true;
    using (SPWeb web = site.RootWeb)
    {
        web.AllowUnsafeUpdates = true;
        string[] aAliases = sAliases.Split(';');
        foreach (string sAlias in aAliases)
        {
            SPUser user = web.EnsureUser(sAlias);
            sAllContacts += user.ID.ToString() + ";#" + user.LoginName.ToString() + ";#";
        }
        web.Update();
    }
}

Wednesday, August 3, 2011

Define managed paths (SharePoint Server 2010)

Published: May 12, 2010
By defining managed paths, you can specify which paths in the URL namespace of a Web application are used for site collections. You can specify that one or more site collections exists at a specified path. This can be a convenient method of consolidating multiple site access for users in various departments.
An explicitly named path (for example, http://server/sites/team) is used for a single site collection. A wildcard path of "sites" (for example, http://server/sites/) indicates that child URLs of the path are site collections.
In this article:

Tuesday, July 26, 2011

Lotus Notes Rich Text Migration to SharePoint Multiline RichText C#.Net DotNet


Currently I am working on the project where I need to migrate Lotus Notes data to sharepoint. I am able to find and migrate all the data using Domino API for .Net. I am facing problem when I am trying to migrate Lotus Notes RichText to SharePoint, It looses its formating and embedded images in the body.
Searching and investigating the approach to solve this problem.
I will keep you posted on this issue.

Friday, July 22, 2011

Developer Dashboard


The Developer Dashboard is an instrumentation framework introduced in Microsoft SharePoint Foundation 2010. Similar in concept to ASP.NET page tracing, it provides diagnostic information that can help a developer or system administrator troubleshoot problems with page components that would otherwise be very difficult to isolate. For example, a developer can easily introduce extra SPSite or SPWeb objects into his or her code unknowingly or add extraneous SQL Server queries.

In the past, the only way to debug performance problems caused by the extra overhead of these instances in code would be to attach a debugger to the code and monitor SQL Server Profiler traces. With the Developer Dashboard, a developer can identify this type of problem, either programmatically by using the object model or visually by looking at page output.

Although performance issues and resource usage information is available in the Unified Logging Service (ULS) logs, interpreting the raw data can be very time consuming. With the Developer Dashboard, all the related information is correlated, which makes identifying these types of issues much easier.

Friday, July 15, 2011

Problem Steps Recorder? ~ Capture Problem on Screen with all Narration.

You can use Problem Steps Recorder to automatically capture the steps you take on a computer, including a text description of where you clicked and a picture of the screen during each click (called a screen shot). Once you capture these steps, you can save them to a file that can be used by a support professional or someone else helping you with a computer problem.

Notes

When you record steps on your computer, anything you type will not be recorded. If what you type is an important part of recreating the problem you're trying to solve, use the comment feature described below to highlight where the problem is occurring.
Some programs, like a full-screen game, might not be captured accurately or might not provide useful details to a support professional.


  • To record and save steps on your computer Open Problem Steps Recorder - c:\Windows\System32\psr.exe. 
  • Click Start Record. On your computer, go through the steps on your computer to reproduce the problem. You can pause the recording at any time, and then resume it later.
  • Click Stop Record.
  • In the Save As dialog box, type a name for the file, and then click Save (the file is saved with the .zip file name extension). 
  • To view the record of the steps you recorded, open the .zip file you just saved, and then double-click the file. The document will open in your browser.

List Attachments over 50MB - increase in Maximum Upload Size

I came across problem during my migration project, where there were few mails in Lotus Notes which are having total size 99 MB and one of the attachment was of 65 MB training video.
Problem:
Default SharePoint settings not allow you to upload more than 50 MB file.
Goal:
Increase the maximum upload size for documents and attachments to 60MB for a web application.
Problem Solution:
  1. Open Central Admin
  2. Navigate to Central Admin > Application Management > Web Application General Settings
  3. Select web application for which you want to increase attachment size limit.
  4. Set the Maximum Upload Size value to 100 MB and hit OK.
Results:
  • Upload a 55MB video to a discussion- success.
  • Attach a 55MB file to a list item - receive the classic "An unknown error occurred" message, scratch head ~ that’s now pathetic.
There is a setting at the IIS level that will block list attachment uploads above 50MB. Below 50MB, works fine and is applied directly through web app settings. Above 50MB, you need to make at least one minor tweak to your web.config to allow larger uploads.
Complete solution for max upload sizes over 50MB:
  1. Connect to Central Admin
  2. Navigate to Central Admin > Application Management > Web Application General Settings
  3. Select your web application
  4. Set the Maximum Upload Size value to "X" (in our case its 100) MB and hit OK.
  5. Repeat steps 6-7 for all zones for your web application on all servers hosting the web application role
  6. Open the web.config
  7. Replace the following line:
    <httpRuntime maxRequestLength="51200" />
    with
    <httpRuntime maxRequestLength="{X * 1024}" />
  8. Still if this is not working then add executionTimeout="999999"

         <httpRuntime executionTimeout="999999" maxRequestLength="{X * 1024}" />

If you are using SQL storage for your SharePoint content, the maximum useful value for the maxRequestLength should be 2097152 (2GB in kilobytes = 2 * 1024 * 1024). Other limits may affect large uploads, most notably:
  • Site Collection Quota
  • Timeouts (you may need to adjust these in BOTH Web Application General Settings and the executionTimeout attribute of the <httpRuntime/> element)
    • Timeout settings will be influenced by network throughput limitations like latency and available bandwidth
  • Custom Storage Solution
    • External Blob Storage solution (see WSS SDK v1.3 for this feature that's new to WSS SP1) - whatever max BLOB size applies
  • Disk Space
    • If using SQL Storage, this is the disk containing your data files for your webapp's content DBs
    • If using an External Blob Storage solution, then this is wherever your blob store resides
For more on the httpRuntime web.config element, see http://msdn2.microsoft.com/en-us/library/e1f13641(VS.80).aspx .