Posts

Showing posts from November, 2008

How to programmatically Create SPListItem in a SPFolder

Sample Code to Create SPListItem in a SPFolder SPSite mySite = new SPSite( "http://[ServerName/sitename]" ); SPWeb web = mySite.OpenWeb(); SPList list = web.Lists[ "ListName" ]; SPFolder f = web.GetFolder( "http://[ServerName/sitename]/Lists/ListName/FolderName" ); if (f.Exists) { SPListItemCollection itemColl = list.Items; SPListItem item = itemColl.Add(f.ServerRelativeUrl , SPFileSystemObjectType.File, null ); item[ "Title" ] = "Added from Code" ; item.Update(); }

Create MySite Programmatically:

SharePoint provides APIs to create MySite programmtically. UserProfile object provides a method to create personal site. Following console application creates MySite for a given account: using Microsoft.Office.Server; using Microsoft.Office.Server.Administration; using Microsoft.Office.Server.UserProfiles; using Microsoft.SharePoint; using System.Web; namespace UserProfileCreate { class Program { static void Main ( string [] args) { using (SPSite site = new SPSite( "http://servername" )) { ServerContext context = ServerContext.GetContext(site); UserProfileManager profileManager = new UserProfileManager(context); string accountName = "domainname\\username" ; UserProfile userProfile; if (profileManager.UserExists(accountName)) { userProfile = profileManager.GetUserProfile(accountName)

Diff B/w SPSite & SPWeb

SPSite class : SPSite Represents a collection of sites on a virtual server, including a top-level site and all its subsites. Each SPSite object, or site collection, is represented within an SPSiteCollection object that consists of the collection of all site collections on the virtual server. SPSite.OpenWeb Method: Returns the site that is located at the specified server-relative or site-relative URL. SPWeb class : SPWeb Simply represents Windows SharePoint Services Web site. Code sample to create a site: SPSite mySite = new SPSite("http://servername/"); SPWeb myWeb = mySite.AllWebs["Site_Name"]; SPWeb myRootWeb = mySite.RootWeb; Note: SPSite and SPWeb inherit directly from System.Object Calling Dispose ensures all resources used by those objects are immediately released.

URL's to access SharePoint Pages

Here are some URL's to access pages in SharePoint. These URL are helpful to save time and hassles of clicking many times to reach a speicfied page: The URL's are grouped based on the major functioanlity area: Users and Permissions: People and Groups: _layouts/people.aspx Site Collection Admins: _layouts/mngsiteadmin.aspx Advanced Permissions: _layouts/user.aspx Master Pages: _Layouts/ChangeSiteMasterPage.aspx Look and Feel: Title, Desc, and Icon: _layouts/prjsetng.aspx Navigation: _layouts/AreaNavigationSettings.aspx Page Layout and Ste Templates: _Layouts/AreaTemplateSettings.aspx Welcome Page: _Layouts/AreaWelcomePage.aspx Tree View: _layouts/navoptions.aspx Top Nav Bar: _layouts/topnav.aspx Site Theme: _layouts/themeweb.aspx Reset to Site Definition: _layouts/reghost.aspx Searchable Columns: _Layouts/NoCrawlSettings.aspx Site Content Types: _layouts/mngctype.aspx Galleries Site Columns: _layouts/mngfield.aspx Site Templates: _catalogs/wt/Forms/Common.aspx List Templates: _ca

SharePoint Search Mystery

SharePoint, like a conductor in an orchestra, really just orchestrates a search request. As a conductor doesn't play an instrument, SharePoint doesn't actually do the mechanics of a search, it just makes the request. It's really all about IFilters and the search capabilities they provide. The SharePoint search pages, object model and web services are just facades to access the real workers. This conversation came up because, out of the box, SharePoint only searches the following content types: .txt, .htm, .doc, .xls, and .ppt. And this search is not SharePoint but rather SQL Servers full-text search engine. After all, a binary file type (like PDF) can't really be searched unless the searcher knows how to read the format. SQL Server knows how to read the base types and with the addition of new iFilters, you can extend that. You can get additional IFilters for PDF, RTF, MSG, ZIP and other formats from various sources (Microsoft has a few free ones like for RT

How to create a Shared Services Provider (SSP)

Image
Creating a Shared Services Provider If the SharePoint Central Administration website isn’t already open, select Start > Administrative Tools > SharePoint 3.0 Central Administration , click the Application Management tab: On the Manage this Farm’s Shared Services page, click the New SSP toolbar button: On the New Shared Services Provider page, in the SSP Name section, click the Create a new Web application link: On the Create New Web Application page, enter the following information, then click the OK button: IIS Website: Port: 1111 Security Configuration: Authentication provider: NTLM Allow Anonymous: No Use SSL: No Load Balanced URL: http://SERVERNAME:1111 (http://vpc02:1111, in this case) Application Pool: Create a new application pool Application pool name: SharePoint – 1111 Select a security account for this application pool: Configurable User name: SERVERNAME\Administrator (VPC02\Administrator, in this case) Password: enter t

Change the Flyout Menu Arrow Hover Color in SharePoint

Image
This is small, but gets me all of the time. When you are working with the Global Navigation (a.k.a. Top Nav Bar) in SharePoint and you are using 2 levels of flyout menus, the arrow that appears for the second level of items may show the wrong background color when you hover over the item or arrow. As you start to alter the various colors and styles in the menu code, the background color behind the arrow does not reflect your changes or seem to pick up any styles from parent elements. Here is an example of this happening. By default, the SharePoint menu code in the master page manually specifies a color for this hover effect: You don't have to replace the color or specify a style, just delete the property and your colors will shine through. This does require edits to the master page, there is no CSS class specified, so you can't change this with CSS only.

How to add to Sub-Sub Menu in SharePoint

Image
MOSS 2007 sites can display drop down menus in the tabbed navigation across the top. Unfortunately there is not an easy check box to act ivate this functionality; instead things just have to be set up the right way. If you want your MOSS site to show drop down menus, make sure the following is true or walk through the following steps: 1. From the root of the parent site (Home) choose to create a new site (Site 1). Once that site is created, you will be in that new site. From here choose to create a new page. 2. Once that is created,choose to create another new site (SubSite 1). Then create a new page in SubSite1 3. Your site structure should resemble like this (Pic Shown below) 4. For each site in the Navigation settings, both Show Subsites and Show Pages should be checked. a. Select Site Actions - Site Settings - Modify Navigation. b. Check Show subsites and Show pages in the first row. 5. The end resul

Add your own icons to SharePoint lists (such as pdf, mp3, etc.).

Upload image in below Path: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES After uploading image Edit this XML file: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML\DOCICON.XML Map the file type to an icon:

How to Backup & Restore SharePoint Sites

To Backup a single site with stsadm when the SharePoint backup/restore process fails, use ( It will create several files. ). stsadm -o export -url "http://localhost/site/subsite" -filename "c:\subsite_files\" To Restore stsadm -o import -url "http:///site/subsite_b" -filename "c:\subsite_files\site.cmp" Replace, if necessary, to your domain or machine and port name.

How to Hide Quick Launch Bar in MOSS 2007

Image
Add the following code in Content Editor webpart and hide this webpart.