Thursday, November 06, 2008

How To Deploy Web Parts in MOSS 2007

Requirement: Deploy Web Part to SharePoint Site.

Procedure:
  1. Build your Web Part with Strong Name: Create a ClassLibrary Project.
  2. Drag and Drop the CustomWebPart.dll to GAC (C:\Windows\Assembly).
  3. Open the VirtualDirectories Folder (C:\Inetpub\wwwroot\wss\VirtualDirectories) and go to the Root Folder of your site. ( For Example your site is "http://localhost:801/sites/TestSite", then open the folder "801".)
  4. Open web.config file and add an SafeControl entry for your web part like, (Note: PublicKeyToken can be copied from GAC).
  5. Reset IIS
  6. Go to your site and Click on "Site Settings" => "Web parts".
  7. Click on "New" web part and Select your Web part and click on "Populate Gallary".
  8. Now go to your site and click on edit page. Click "Add a Web part". Select your web part under "Miscellaneous" section and click on "Add".
  9. You can see your web part now.
Deploy Web part by building Cab file.
  1. Build your Web Part with Strong Name: Create a ClassLibrary Project.
  2. Drag and Drop the CustomWebPart.dll to GAC (C:\Windows\Assembly).
  3. Add "CustomWepPartCab" cab project to the above solution(File => New => Project => Other Project Types => Setup and Deployment Project => Cab Project => "CustomWepPartCab")
  4. Add "Project Output.." by right click on cab project.
  5. Select "Primary output" and "Content Files".
6. Add a new file "manifest.xml" to the cab project as follows:
Note: Please make sure that file name(manifest.xml) is not changed

"











"

7. Add another file with name "CustomWebPart.dwp", the name given in the maifest.xml file as follows:
"

Custom Webpart
Custom Webpart
CustomWebpart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b6ad7af95de74642 publickeytoken value from GAC
CustomWebpart.CustomWebpart

"

Deploying the Cab file:
  1. Go to command prompt(Start => Run => Cmd)
  2. Change the directory to the location where cab file(CustomWebPart.cab) is build.
  3. Execute the following command
  4. stsadm.exe -o addwppack -filename WebPartCab.CAB -url http://SiteUrltoInstallWebPart -globalinstall -force

Wednesday, November 05, 2008

Limiting Search Scope to Wiki Page Library(Document Library) AND Hiding Scope Drop Down

Hi,

I want to search a single Wiki Page Library(or Document Library) and I want to hide the Scope DropDown in UI.

For this, I found some solutions:

1)Create a Wiki Page Library(or Document Library) and note down the URL for later use.(For ex: "http://idc-dk-is:44510/sites/TestSite/WikiPageLibrary", Don't forget to remove the "/Forms/AllPages.aspx" from the URL).

2)Open SharePoint Designer and Open your master page where youwant to include this search.

3) From the main Menu, select "Task Panes" and Check/Select "Web Parts". It will open "Web Parts" task pane on the right hand side of the designer.

4) From the "Web Part List", Filter by "Search" and drag and drop "Search Box" web part to your master page.

5) Select "Code" view for the master page.
To hide the Scope Drop Down, set the following property:
<DropDownModeEx xmlns="urn:schemas-microsoft-com:SearchBoxEx">HideScopeDD

6) To specify search in the specific document library, you need to set two properties, "AppendToQuery" to false and "AppQueryTerms" to the Document Library Url (from step 1) as follows in the Search Webpart.

In spswc:searchboxex, AppendToQuery="false" AppQueryTerms="site:http://idc-dk-is:44510/sites/TestSite/WikiPageLibrary"


Another Solution:


1) Follow the Step 1 specified above to create Wiki Page Library

2)Create a Search Scope For the Document Library and note down the Scope name(For example: WikiSearch with scope rule ( Type = Web Address and Web Address = Folder,"http://idc-dk-is:44510/sites/TestSite/WikiPageLibrary")

3)Follow the steps from 2 to 5 specified in above solution.

4)To specify search in the specific document library, you need to set two properties, "AppendToQuery" to false and "AppQueryTerms" to "Scope:DocLibrarySearchScopeName" as follows.

In spswc:searchboxex webpart,
AppendToQuery="false" AppQueryTerms
Scope:WikiSearch"

Save the modified Master Page and publish it to see the Search returning results from the Doc Library only.

Happy Searching...
Yasovardhan.

Monday, October 27, 2008

To Change the seperator icon after "My Site" and "My Links" in the top right corner of SharePoint HomePage

Since the existing seperator pipe icon('') immediatly after "My Site" and "My Links" is incorporated in "MySite" feature, it can't be directly pointed/changed to some other image, by using SharePoint Designer. For this we need to create a new feature and use this feature instead of existing feature. Please follow the steps mentioned below for that.

1) Copy the new image to SharePoint "Images" folder (i.e "C:\program files\common files\microsoft shared\web server extensions\12\TEMPLATE\IMAGES")

2) Create a new feature in FEATURES folder:
  • Go to FEATURES folder (i.e. "C:\program files\common files\microsoft shared\web server extensions\12\TEMPLATE\FEATURES").
  • Copy the existing "MySite" feature.(Select "MySite" folder) and paste it there.
  • Name the feature as "NewMySite" by renaming the copied folder.
  • It will contain two xml files namely "Feature.xml" and "
    MySiteFeatureElements.xml".

3) Modify "Feature.xml" file:

  • Open the "Feature.xml" in Visual Studio IDE.
  • Create a GUID and replace the Feature Id in the xml with the new GUID.

(To generate GUID, go to the folder "C:\Program Files\Microsoft Visual Studio 8\Common7\Tools" and click on "guidgen.exe" and copy the GUID generated. If you want to have shortcut for generating GUID in the Visual Studio IDE, open Visual Studio IDE. Click on "Tools", then "External tools". In the Dialog window, add the following.

Title : Create &GUID

Command: C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\guidgen.exe

Initial Directory: C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\

Then, click on "OK". Next time Go to "Tools" and click on "Create GUID" to generate new GUID.

  • Replace the "Farm" with "Web" for "Scope" attribute.
  • Replace "TRUE" with "FALSE" for "Hidden" attribute.
  • Save the "Feature.xml" file.

4) Modify "MySiteFeatureElements.xml" file

  • In the xml file, modify the "Sequence" value from 100 to less value (like 90) for each of the three controls.
  • Create new user controls in CONTROLTEMPLATES folder to be pointed in this xml file.
  • Go to CONTROLTEMPLATES folder i.e. "C:\program files\common files\microsoft shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES"
  • Copy "MySiteLink.ascx" file and paste it and rename it to "NewMySiteLink.ascx".
  • In "newMySiteLink.ascx" file, comment/remove the two lines and insert an image which points to the new image in _layouts folder like:

*

  • Similary copy "MyLinks.ascx" file and paste it & rename it to "NewMyLinks.ascx".
  • Edit the file and comment/remove line and insert new line for image as above.
  • Save the both files
  • Replace the "ControlSrc" urls with the new ascx files created in the above steps as follows:





  • Save the file.

5) Modify the scope in master page file:

Since the default scope of the SharePoint Delegate controls "GlobalSiteLink1" and "GlobalSiteLink2" is "Farm", we don't want to affect these changes in entire farm level, we need to change it to "Web" scope. For that open SharePoint Designer. Open your default master page and change the scope of "GlobalSiteLink1" and "GlobalSiteLink2" Delegate controls to "Web" level.

Web" runat="server"/>

Web" runat="server"/>

6) Install Feature:

  • Open Command Prompt and change the directory to "C:\program files\common files\microsoft shared\web server extensions\12\BIN".
  • Execute the installfeature command as follows

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o installfeature -filename NewMySite\Feature.xml -force

7) Activate the Feature to your Site collection:

  • Execute the activatefeature command as follows.

C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN>stsadm -o activatefeature -filename NewMySite\Feature.xml -url http://idc-dk-is:44510/sites/TestSite

8) Reset IIS

9) Open your web site and check the change in the seperator image.

Tuesday, October 07, 2008

Site Restore Problem


When I try to restore a site collection using "stsadm -o retore" command it is giving the following error.
"Your backup is from a different version of Windows SharePoint Services and cannot be restored to a server running the current version. The backup file should be restored to a server with version '12.0.0.6318' or later."

I figured out that my SharePoint version is '12.0.0.6300' (Go to any SharePoint site in the system.Click on Site Settings. It will display the version number as attached in screen shot") The solution is to upgrade my SharePoint to version 12.0.0.6318. I found the link for downlod in the following url:

http://www.microsoft.com/downloads/details.aspx?FamilyID=256CE3C3-6A42-4953-8E1B-E0BF27FD465B&displaylang=en

Download it and install. Now the site restore should work.

Monday, October 06, 2008

Site Administration problem after restoring backup of another person's site collection

When you create a new site collection and restore site collection created by another person, it will restore and replace the site collection administartors from that site. To replace it with your name, go to SharePoint Central administration and click on Site Collection Administartors in Application Managemnt. type your account name as primary administrator and click ok. Now you can go to the site collection and modify all settings.

Tuesday, September 16, 2008

Site BackUp and Restore using STSADM command

Take backup using stsadm command

stsadm.exe -o backup -url <> -filename "<>" -overwrite

Ex: stsadm.exe -o backup -url http://idc-dk-is:801/sites/SalesLibrary -filename "E:\SP Backup\SalesLibraryBackUp.dat" -overwrite

Restore site using stsadm command

stsadm.exe -o restore -url <> -filename "<>" -overwrite

Ex: stsadm.exe -o restore -url http://idc-lt-i00142:20533/sites/saleslibrary -filename "D:\SP Backup\ SalesLibraryBackUp.dat" -overwrite

Friday, July 04, 2008

How to convert string into currency format in C#

string strAmount = 100000;
double dblAmount = Convert.ToDouble(strAmount );

string strAmountInCurrency = string.Format("{0:$#,#.00}", dblAmount ); //returns $1,00,000.00 as result