Thursday, April 12, 2012

How to tell if you are on WSS site/MOSS 2007 site?

I often come across confusion around branding options and navigation customizations for WSS v3 sites. One of the first questions I ask is if the WSS v3 site is on a server with only WSS v3 installed, or is it on a server where MOSS 2007 has also been installed. This often adds to the confusion.
In addition to the differences between MOSS 2007 and WSS v3, there are differences in WSS sites depending on if the host server also has MOSS 2007 installed. In regards to branding and navigation, WSS sites NOT on a server with MOSS do not have the option to set a Master Page in the Site Settings, nor can they have drop downs added out-of-the-box to the tabbed horizontal navigation.
You can easily check to see if your WSS site is hosted on a server with MOSS installed by checking the Site Settings for the WSS site.
1. Go to Site Actions - select Site Settings
2. Look under the Look and Feel category. If you see:
o Top link bar, you have a WSS site on a server with only WSS installed.
o Master Page and Navigation, you have a WSS site on a server with MOSS installed.
See the below screenshot of a stand-alone WSS site.

See the below screenshot of a WSS site on a server with MOSS. All Site Setting differences have been marked.

For WSS only servers, you will have to set a custom master page for the site using SharePoint Designer. For drop down navigation, you will need to add a custom navigation solution to your master page.
As a side note, another user interface difference between the two is the Content Query Web Part (CQWP). The CQWP is a component of MOSS, so it is only available on WSS sites hosted a server with MOSS installed. Click below for info on how to customize the CQWP.
http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx

Monday, January 9, 2012

Accessing Custom Aspx Page in MOSS 2007 Site

Hi,

There would be requirement where we could have developed our custom aspx page and we have to deploy the same on SharePoint site. To do this first we need to paste that folder which consists of aspx page in the below path of the machine
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS

Now we can access our custom aspx page by accessing in the below format of the site
http://servername:portno/_layouts/foldername/customaspxpagename.aspx

For the example through Visual studio I have created a folder Custom and aspx page name would be custompage.So I can access the page with the following url
http://servername:portno/_layouts/ Custom /custompage.aspx

Thursday, October 27, 2011

SharePoint Tools

There are n number of tools for SharePoint,but below are the list of the tools that i used in my career for better understanding while dealing with MOSS 2007/WSS sites.Glance the list of SharePoint tools as below

SharePoint tools- The list is growing 
1. App Pool Manager (http://www.harbar.net/apm/apm2.zip)
2. U2U CAML Query Builder (http://www.u2u.info/SharePoint/U2U%20Community%20Tools/U2U%20Caml%20Query%20Builder%202007%20v3.1.0.0%20(windows%20version).zip)
3. .NET Reflector (http://reflector.red-gate.com/download.aspx)
4. SharePoint Explorer for WSS 3.0 ( )
5. SharePoint Log Reader (http://www.blogaboutsharepoint.com/wp-content/plugins/download-monitor/download.php?id=1)
6. BDC Meta Man Tool (http://www.lightningtools.com/pages/service/customerdownloads.aspx)
7. SharePoint Inspector 1.0.0.0 (http://spi.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=1652#DownloadId=5854)
8. SharePoint Explorer for WSS 3.0 (http://download.mondosoft.com/Ontolica/SharePointExplorer_V1_5_1_For_WSS3.zip)
9. SharePoint Dispose Checker Tool (http://download.microsoft.com/download/B/4/D/B4D279A0-E159-40BF-A5E8-F49ABDBE95C7/SPDisposeCheck.msi)
10. Windows SharePoint Services 3.0 SDK (http://www.microsoft.com/downloads/details.aspx?familyid=05E0DD12-8394-402B-8936-A07FE8AFAFFD&displaylang=en)
11. Microsoft Office SharePoint Server 2007 SDK (http://www.microsoft.com/downloads/details.aspx?familyid=6D94E307-67D9-41AC-B2D6-0074D6286FA9&displaylang=en)
12. Microsoft InfoPath 2007
13. Microsoft SharePoint Designer 2007
14. Microsoft Office 2007
15. WSP Builder for SharePoint (http://www.codeplex.com/wspbuilder)
16. Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions (http://www.microsoft.com/downloads/details.aspx?FamilyID=3e1dcccd-1cca-433a-bb4d-97b96bf7ab63&DisplayLang=en)
17. Windows SharePoint Services 3.0 Tools: Visual Studio 2008 Extensions (http://www.microsoft.com/downloads/details.aspx?familyid=7BF65B28-06E2-4E87-9BAD-086E32185E68&displaylang=en)
18. SharePoint Administration Toolkit v2.0
x64: http://www.microsoft.com/downloads/details.aspx?FamilyId=F8EEA8F0-FA30-4C10-ABC9-217EEACEC9CE&displaylang=en
x86: http://www.microsoft.com/downloads/details.aspx?FamilyId=263CD480-F6EB-4FA3-9F2E-2D47618505F2&displaylang=en
19. SmartPart (http://www.codeplex.com/smartpart)
20. SharePoint Installer (http://www.codeplex.com/sharepointinstaller)
21. SOAP calls to the SharePoint web services (http://www.soapui.org/)
22. Microsoft Network Monitor 3.2 (http://www.microsoft.com/downloads/details.aspx?FamilyID=f4db40af-1e08-4a21-a26b-ec2f4dc4190d&DisplayLang=en#filelist ) Thanks to Patel for providing me this link.
23. SharePoint Work Acceleration Toolkit 2007 aka (SWAT) (http://www.idevfactory.com/products/swat/)
24. MetaVis Architect for SharePoint (www.metavistech.com/architect)
25. SharePoint 2007 Test Data Population Tool (http://www.codeplex.com/sptdatapop) Capacity planning and performance testing tool that populates data for testing SharePoint deployments
26. Imtech Test Content Generator v1.3.0.0
(http://blog.mastykarz.nl/imtech-test-content-generator-v1300-free-sharepoint-2007-tool/)
Creating a given number of publishing pages with the desired page layout and content
27. SharePoint Tips Utility Pack
(http://www.codeplex.com/spstipsUtilityPack)
Collection of tools including recursively delete sites, create and modify lists in multiple sites at once, and push a web part to multiple sites at once.
28. SharePoint Cross-site Configurator
(http://www.codeplex.com/SPConfigurator)
Automates the process of deploying MOSS site settings in all or selected sites in a server farm. Includes applying master pages, web titles, audit controls and expiration policies.
29. SharePoint Content Deployment Wizard
(http://www.codeplex.com/SPDeploymentWizard)
Allow a granular selection of content to be exported from site collections, webs, lists, folders, and list items to a .cmp file (Content Migration Package) which can be copied to other servers for import.
30. Sushi Tool for SharePoint
(http://www.codeplex.com/sushi)
Performs common administrative tasks. Can backup sites, copy views between sites, bulk create sites, apply themes just to name a few functions
31. SharePoint Developer Bookmarklets
(http://blog.mastykarz.nl/go/bookmarklets)
Great set of bookmarks to make navigating a SharePoint Web Site easier.
32. LINQ to SharePoint
(http://www.codeplex.com/LINQtoSharePoint)
Provides a custom query provider for LINQ that allows the querying of SharePoint lists using LINQ syntax
33. SharePoint config store
(http://www.codeplex.com/SPConfigStore)
Provides the framework for using a SharePoint list for application configuration values
34. SharePoint Dispose Checker Tool
(http://code.msdn.microsoft.com/SPDisposeCheck)
Helps to check that unmanaged SharePoint objects are correctly disposed of in code
35. PowerShell Extensions for SharePoint
(http://www.codeplex.com/SPPSExtensions)
Provides functionality for working with the SPWeb object.
36. SharePoint Automation
(http://stsadm.blogspot.com)
Extensions that assist in the use of working with the SharePoint object model from PowerShell.
37. The SharePoint PowerShell Module (SPoshMod)
(http://www.codeplex.com/SPoshMod)
Framework for SharePoint PowerShell scripts.
38. AC's WCM Custom Commands for STSADM.EXE
(http://www.andrewconnell.com/blog/articles/MossStsadmWcmCommands.aspx)
STSADM extensions for publishing sites and generating content type and column features.
39. Imtech OCD Export
(http://blog.mastykarz.nl/export-publishing-pages-features-imtech-ocd-export-page/)
Simplifies the process of provisioning Publishing Pages by extracting existing pages to XML. The files generated allow you to wrap your Publishing Pages in a Feature.
40. SharePoint Automation
(http://stsadm.blogspot.com)
List of almost 100 STSADM extensions that cover a variety of development and administrative tasks.
41. stsadmWin 2007
(http://blogs.msdn.com/ronalus/archive/2007/01/04/stsadmwin-has-an-2007-version.aspx)
Provides a Windows UI version of the STSADM tool
42. SharePoint 2007 Features
(http://www.codeplex.com/features)
Large collection of SharePoint features designed for developers and administrators. Provides assistance for debugging, logs, field and content type development, publishing sites, event receivers, and many more.
43. SmartTools for SharePoint
(http://www.codeplex.com/smarttools)
Collection of SharePoint features such as What's New, Auto complete Text Field, Enhanced Site Actions, and more
44. Yet Another CAML Query Tool
(http://www.ideseg.com/SharePointYetAnotherCAMLQueryTool2.aspx)
Converts SQL-like queries into CAML.
45. Imtech ListInstance Generator
(http://blog.mastykarz.nl/generating-list-instances-xml-imtech-listinstance-generator/)
Generates the ListInstance based on the List Template from a particular Feature
46. CAML.NET
(http://www.codeplex.com/camldotnet)
Set of .NET language-based tools for creating dynamic, reusable CAML query components. Build CAML queries dynamically in code while preserving the syntactic structure of the native CAML language.
47. SharePoint Manager
(http://www.codeplex.com/spm)
SharePoint object model explorer for inspecting your SharePoint environment. Can browse every site on the local farm and view every web, list, event receiver, etc... Enables the changing of properties
48. RedGate Reflector
(http://www.red-gate.com/products/reflector/)
Allows exploration of any .NET assembly, including those provided by SharePoint. Shows where and how methods and objects are used. Find feature for fields, properties, and methods.
49. Search Community Toolkit
(http://www.codeplex.com/sct)
A number of tools and code samples that have been contributed to enhance the Microsoft search experience (Microsoft Office SharePoint Server 2007 (MOSS) Search, Search Server 2008 and Search Server 2008 Express).
50. SharePoint Search Service Tool
(http://www.codeplex.com/SharePointSearchServ)
Web service client that can explore the scopes and managed properties of a given SharePoint Search SSP, build queries in either Keyword or SQL Syntax, submit queries, and examine the raw web service results.
51. zevenseas SharePoint Search Coder
(http://www.codeplex.com/MOSSSearchCoder)
Allows graphical building of queries and examination and testing of the SQL generated by the object model.
52. SharePoint Query Web Service Test Tool
(http://www.wsssearch.com/querywebservice.html)
Test tool for WSS V3's Query web service. Allows you to generate the request XML and send it to the web service.
53. STORM
(http://storm.codeplex.com/)
Tests any web service (including SharePoint)
54. Fiddler
(http://www.fiddlertool.com/fiddler/)
Examines the network traffic of pages as they load. Check the size of pages. Recommended for deploying public facing websites.
55. Firebug for Firefox
(http://getfirebug.com/)
Net console provides network statistics.
56. YSlow for Firebug for Firefox
(http://developer.yahoo.com/yslow/)
Analyses page performance and provides network statistics
57. SharePoint Development Environment Modifications (SPDevMod)
(http://www.codeplex.com/SPDevMod)
Collection of STSADM extensions and plugins for Visual Studio
58. Code Rush/Refractor Tools for SharePoint Developers
(http://andrewconnell.com/blog/articles/ProductivityToolsForSharePointDevelopers.aspx)
Extensions to Code Rush/Refractor to assist SharePoint development.
59. Imtech Fields Explorer Visual Studio 2008 plug-in
(http://blog.mastykarz.nl/imtech-fields-explorer-visual-studio-2008-plugin/)
Quickly find the field names needed for CAML queries and controls
60. Microsoft - BDC Definition Editor
(http://blogs.msdn.com/sharepoint/archive/2007/08/22/announcing-the-microsoft-business-data-catalog-definition-editor-for-microsoft-office-sharepoint-server-2007.aspx)
61. ARF is a FREE development framework for SharePoint
(http://www.spworks.co.uk/downloads/latest.aspx)
62. CSS Friendly Adapters
(http://www.sharepointblogs.com/mossman/archive/2007/03/08/css-friendly-control-adapters-in-sharepoint-2007-a-walk-through.aspx)
63. Mobile Entrée(TM) is the first ever SharePoint mobile application framework (http://www.mobileentree.com/default.aspx)
64. The SharePoint branding tool for easy configuration of themes, logos, etc. (http://download.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=BrandingTool&DownloadId=66138&FileTime=128847754111100000&Build=15896)
65. SharePoint Deployment tool / Capacity planning tool (http://www.microsoft.com/downloads/details.aspx?FamilyId=DBEE0227-D4F7-48F8-85F0-E71493B2FD87&displaylang=en) with instructions on how to use it (http://technet.microsoft.com/en-us/library/bb961988.aspx)
66. SharePoint Site Manager 2007 (http://spm.codeplex.com/releases/view/22762)
67. Debug View for windows (An excellent tool for tracing/debugging) (http://download.sysinternals.com/Files/DebugView.zip)

Thursday, May 12, 2011

Creating windows service for creating sites

Hi,
I am posting three ways of approaches that I followed to create windows service for creating sites
First Approach: In this approach I created a xml where I have saved the process names, owner login, owner name. From this xml I am taking process names and creating the sites in Console Application
Here through code I have taken care of displaying the message if site already exists
o Deployment : Xml file, Console Application exe and Console Application exe config files to be moved from test server to dev/production server
o Solution file : CreateSiteCA.zip

Second Approach : In second approach I created a bat file and I have written stsadm commands to create the sites
o Deployment : Bat file needs to be moved from test server to dev/production server
o Solution file : createsite.bat

Third Approach : In this approach I have created list in which I have saved process names, owner login, owner names. From this list I am fetching the process names and creating the sites
Here through code I have taken care of displaying the message if site already exists
o Deployment : List template, Console Application exe and Console Application exe config files to be moved from test server to dev/production server
o Solution file : CreateSitefromListCA.zip
----------------------------CreateSiteCA.zip--------------------

// App.config, Configurations.xml can be found as below




//Program.cs
using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

using System.Configuration;
using System.Xml;

namespace CreateSiteCA
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite(ConfigurationSettings.AppSettings["SiteCollectionURL"]))
{
SPWebApplication webApp = site.WebApplication;
//Random rand = new Random();
//int index= rand.Next(1000);
//SPSite newSite= webApp.Sites.Add("/sites/TestSite" + index, "This is my Test Site",
// "This is the First Site Added Programmatically", 1033,
// "STS#0", @"domain\username", "username", "username@domain.com");

XmlDocument doc = new XmlDocument();
doc.Load("Configurations.xml");

XmlNodeList list = doc.SelectNodes("Sites/Site");
foreach (XmlNode node in list)
{
if (webApp.Sites["/sites/" + node.Attributes["name"].Value] != null)
{
Console.WriteLine("Site by name '" + node.Attributes["name"].Value + "' already exists " + Environment.NewLine);
continue;
}
Console.WriteLine("Please wait currently creating new site.." + Environment.NewLine);
SPSite newSite = webApp.Sites.Add("/sites/" + node.Attributes["name"].Value, node.Attributes["title"].Value,
node.Attributes["description"].Value, Convert.ToUInt32(node.Attributes["nLCID"].Value), node.Attributes["webTemplate"].Value,
node.Attributes["ownerLogin"].Value, node.Attributes["ownerName"].Value, node.Attributes["ownerEmail"].Value);

if (newSite != null)
{
Console.WriteLine("Site Created: " + newSite.Url + Environment.NewLine);
newSite.Dispose();
}
else
{
Console.WriteLine("Error Creating:" + node.Attributes["name"].Value + Environment.NewLine);
}
}
Console.WriteLine("Site Creation Compleated. Please press any key to continue..");
Console.ReadLine();
}
}
}
}

-------------------------------------------------------- createsite-----------------------------------------------------
//createsite.bat
@echo off

echo ===============================================================

echo Creating the sites

echo ===============================================================

cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\BIN

@echo off

stsadm -o createsite -url "http://servername:portno/sites/testsite6" -owneremail "username@domain.com" -ownerlogin "domain\username" -title "test site" -description "test site"

echo completed

--------------------------------------------------- CreateSitefromListCA-----------------------------------------

// App.config can be found as below



//Program.cs
using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

using System.Configuration;

namespace CreateSitefromListCA
{
class Program
{
static void Main(string[] args)
{
using (SPSite objsite = new SPSite(ConfigurationSettings.AppSettings["SiteCollectionURL"]))
{

using (SPWeb objweb = objsite.OpenWeb())
{
SPList objlist = objweb.Lists["Process List"];
SPListItemCollection objitmcollection = objlist.Items;
SPWebApplication objwebapp = objsite.WebApplication;

for (int i = 0; i < objlist.ItemCount; i++)
{
string processname = Convert.ToString(objitmcollection[i]["Title"]);
string strownerlogin = Convert.ToString(objitmcollection[i]["owner login"]);
string strowneremail = Convert.ToString(objitmcollection[i]["owneremail"]);
//if ((objwebapp.Sites.WebApplication.Name)!=processname.n)
//{
try
{
objwebapp.Sites.Add("/sites/" + processname, "This is my Test Site", "", 1033, "STS#0", @"domain\username", strownerlogin, strowneremail);
Console.WriteLine(processname + " Site Created");
}
catch (System.Exception _Ex)
{
Console.WriteLine("A Site with title: " + processname + " already exists");
}

// Console.ReadLine();
//}


}
}


}
}
}
}

Monday, September 6, 2010

Adding custom field into sharepoint

Hi,
First of all thanx to SharePointKings site
First in my Control.ascx i have written as below and had put in 12hive\TEMPLATE\CONTROLTEMPLATES path
<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>



After that in my fldtypes_control.xml I have written as below and had put in 12hive\TEMPLATE\XML



SPKings Textbox
SPKings Textbox
SPKings Textbox
Text
SharePointKings.CustomControls.SPKingsTextBoxField, SharePointKings.CustomControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0dcfd7c46d44c992
TRUE
TRUE


After that in SPKingsTextboxControl.cs I have written as follows
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls;
namespace SharePointKings.CustomControls
{
public class SPKingsTextboxControl:BaseFieldControl
{
protected TextBox txtTextBox;
///
/// setting template name
///

protected override string DefaultTemplateName
{
get
{
return @"SPKingsTextbox";
}
}

///
/// get set value
///

public override object Value
{
get
{
EnsureChildControls();
return txtTextBox.Text.Trim();
}

set
{
EnsureChildControls();
txtTextBox.Text = (string)this.ItemFieldValue;
}
}
///
/// create child control
///

protected override void CreateChildControls()
{
if (Field == null) return;
base.CreateChildControls();
}

}
}

After that in SPKingsTextBoxField.cs I have written as
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
namespace SharePointKings.CustomControls
{
class SPKingsTextBoxField:SPFieldText
{
#region Contstructors
public SPKingsTextBoxField(SPFieldCollection fields, string fieldName): base(fields, fieldName)
{
}
public SPKingsTextBoxField(SPFieldCollection fields, string typeName, string displayName) : base(fields, typeName, displayName)
{

}

#endregion
public override string GetValidatedString(object value)
{
string strTxtValue = Convert.ToString(value).Trim();

if (!strTxtValue.ToUpper().StartsWith("HTTP") &&
!strTxtValue.ToUpper().StartsWith("FTP"))
{
throw new SPFieldValidationException("Web address does not start with HTTP or FTP");
}
return strTxtValue;
}
}
}

Tuesday, June 15, 2010

Matching the site urls with list item urls

Recently we had an requirement of webpart where it should fetch all the site under that Web Application and check the urls from the list where some urls are already saved.After checking it should display URL's that are available in the list,List of all the sites under the current Web Application,sites that are not available in the list,list URL's are not available in the current Web Application and soon as user clicks the Delete button it should delete the urls in the list which are not alive

using System;

using System.Linq;

using System.Text;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using System.Collections;

using System.Collections.Generic;

using System.Collections.Specialized;

using System.IO;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Administration;

using Microsoft.SharePoint.WebPartPages;

using System.Web.UI.WebControls.WebParts;

namespace RequestSiteDocument

{

public class RequestSiteDocument : System.Web.UI.WebControls.WebParts.WebPart

{

Button btnCreate;

Button btnDelete;

Label lblException;

private bool customMessage = true;


SPWeb oweb = SPContext.Current.Web;

SPSite objsite = SPContext.Current.Site;

SPList objlist = null;



ArrayList arrListofWebHierarchy = new ArrayList();

ArrayList arrListURLInfo = new ArrayList();

ArrayList arrListofsitenames = new ArrayList();

ArrayList arrListURLInfoinDeletebutton = new ArrayList();

ArrayList arrListListofWebHierarchyinDeletebutton = new ArrayList();

ArrayList arrListfordeletelist = new ArrayList();

ArrayList arrListofsitenamesinDeletebutton = new ArrayList();


protected override void CreateChildControls()

{

base.CreateChildControls();



if (DisplayButton)

{

btnCreate = new Button();

btnCreate.ID = "btnCreate";

btnCreate.Text = "Create";

btnCreate.Click += new EventHandler(btnCreate_Click);

btnCreate.Visible = true;

this.Controls.Add(btnCreate);

btnDelete = new Button();

btnDelete.ID = "btnDelete";

btnDelete.Text = "Delete";

btnDelete.Click += new EventHandler(btnDelete_Click);

btnDelete.Visible = true;

this.Controls.Add(btnDelete);

}

lblException = new Label();

lblException.ID = "";

lblException.Visible = true;

this.Controls.Add(lblException);

}

void btnCreate_Click(object sender, EventArgs e)

{

throw new NotImplementedException();

}



[Personalizable(PersonalizationScope.Shared),

WebBrowsable(true),

WebDisplayName("Display button"),

WebDescription("Display button"),

SPWebCategoryName("Display button")]

public bool DisplayButton

{

get { return customMessage; }

set { customMessage = value; }

}



protected override void Render(System.Web.UI.HtmlTextWriter writer)

{

base.Render(writer);

//SPSite objsite = SPContext.Current.Site;


SPWebCollection objspw = objsite.AllWebs;

try

{

objlist = oweb.Lists["RequestASiteList"];

if (objlist != null)

{

writer.Write("");

writer.Write("");

writer.Write("");

writer.Write("");

foreach (SPListItem itmlist in objlist.Items)

{

writer.Write("");

writer.Write("");

writer.Write("");

arrListURLInfo.Add(strurl);

writer.Write("");

}

writer.Write("
URL's that are available in the list
Site TitleSite URL
");

string strsitetitle = (itmlist["Title"].ToString().ToLower());

writer.Write(strsitetitle);

writer.Write("
");

string strurl = (itmlist["url"].ToString()).ToLower();

writer.Write(strurl);

writer.Write("
");

}

writer.Write("");

writer.Write("");

writer.Write("");

writer.Write("");

//fetching all the site names and site urls

foreach (SPWeb objweb in objspw)

{

writer.Write("");

writer.Write("");

writer.Write("");

writer.Write("");

//adding all site url's to the array list called arrListofWebHierarchy

arrListofWebHierarchy.Add(objwebfullurl);

arrListofsitenames.Add(objweb.Title);

}

writer.Write("
List of all the sites under the current Web Application
Site NameSite URL
");

writer.Write(objweb.Title);

writer.Write("
");

writer.Write(objweb.Url);

string objwebfullurl = (objweb.Url).ToLower() + "/default.aspx";

writer.Write("
");

writer.Write("");

writer.Write("Below sites are not available in the list");

int sitefoundflag = 0;

//Compare arrListofWebHierarchy with arrListURLInfo

for (int i = 0; i < arrListofWebHierarchy.Count; i++) { for (int j = 0; j < arrListURLInfo.Count; j++) { if (arrListofWebHierarchy[i].ToString().CompareTo(arrListURLInfo[j].ToString().Trim()) == 0) { sitefoundflag = sitefoundflag + 1; } } if (sitefoundflag <= 0) { writer.Write("
");

writer.Write("Site Name:" + arrListofsitenames[i]);

writer.Write("");

writer.Write("URL:" + arrListofWebHierarchy[i]);

writer.Write("");

}

else

{

sitefoundflag = 0;

}

}

writer.Write("");

writer.Write("Below list URL's are not available in the current Web Application");

int listflag = 0;

//Compare arrListURLInfo with arrListofWebHierarchy

for (int i = 0; i < arrListURLInfo.Count; i++) { for (int j = 0; j < arrListofWebHierarchy.Count; j++) { if (arrListURLInfo[i].ToString().CompareTo(arrListofWebHierarchy[j].ToString().Trim()) == 0) { listflag = listflag + 1; } } if (listflag <= 0) { writer.Write("
");

writer.Write(arrListURLInfo[i]);

arrListfordeletelist.Add(arrListURLInfo[i]);

writer.Write("");

}

else

{

listflag = 0;

}

}

}

catch (Exception ex)

{

lblException = new Label();

lblException.Text = ex.ToString();

}

}


void btnDelete_Click(object sender, EventArgs e)

{

try

{

SPWebCollection objspw = objsite.AllWebs;

//get the url's that are available in the list field called url

objlist = oweb.Lists["RequestASiteList"];

if (objlist != null)

{

foreach (SPListItem itmlist in objlist.Items)

{

string strurl = (itmlist["url"].ToString()).ToLower();

arrListURLInfoinDeletebutton.Add(strurl);

}

}

//fetching all the site names and site urls

foreach (SPWeb objweb in objspw)

{

string objwebfullurl = (objweb.Url).ToLower() + "/default.aspx";

//adding all site url's to the array list called arrListListofWebHierarchyinDeletebutton

arrListListofWebHierarchyinDeletebutton.Add(objwebfullurl);

arrListofsitenamesinDeletebutton.Add(objweb.Title);

}

int listflag = 0;

//Compare arrListURLInfoinDeletebutton with arrListListofWebHierarchyinDeletebutton

for (int i = 0; i < arrListURLInfoinDeletebutton.Count; i++)

{

for (int j = 0; j < arrListListofWebHierarchyinDeletebutton.Count; j++)

{

if (arrListURLInfoinDeletebutton[i].ToString().CompareTo(arrListListofWebHierarchyinDeletebutton[j].ToString().Trim()) == 0)

{

listflag = listflag + 1;

}

}

if (listflag <= 0)

{

arrListfordeletelist.Add(arrListURLInfoinDeletebutton[i]);

}

else

{

listflag = 0;

}

}

SPList olist = oweb.Lists["RequestASiteList"];

SPListItemCollection itmcollection = olist.Items;

for (int i = 0; i < arrListfordeletelist.Count; i++)

{

for (int j = 0; j < itmcollection.Count; j++)

{

SPListItem objsplistitem = itmcollection[j];

if (arrListfordeletelist[i].ToString() == (objsplistitem["url"].ToString()).ToLower())

{

itmcollection.Delete(j);

}

}

}

}

catch (Exception ex)

{

lblException.Text = ex.ToString();

}


}

}

}

Saturday, March 27, 2010

Customising Welcome message of the site

Hi,


There may be the situation where you may have to customise the welcome message which will be on the right top of the site.For that i got the good link.Now my requirement was displaying the message based upon the intranet/extranet site.For that initially i have written the below code in welcome.ascx but the problem is it use to execute if condition always


Finally after seeing the link


http://www.wictorwilen.se/Post/Having-fun-with-the-SharePoint-Welcomeascx-control.aspx


what i did is


I took a custom user controlcustomwelcome.ascx and copy pasted the code of welcome.ascx in it and I have wriiten code in webpart as


namespace CustomWelcome {


public class Welcome : Microsoft.SharePoint.WebControls.Welcome {


protected Welcome() {


}


[SharePointPermission(SecurityAction.Demand, ObjectModel = true)]


protected override void OnLoad(EventArgs e)


{


base.OnLoad(e);


if (HttpContext.Current.User.Identity.IsAuthenticated)


{


if (HttpContext.Current.User.Identity.AuthenticationType==”Forms”)


{


PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0]


as PostCacheSubstitutionText;


pt.TextType = PostCacheSubstitutionTextType.UserName;


pt.SuffixHtml=”(Extranet)”


}


Else


{


PostCacheSubstitutionText pt = base.ExplicitLogout.MenuControl.Controls[0]


as PostCacheSubstitutionText;


pt.TextType = PostCacheSubstitutionTextType.UserName;


pt.SuffixHtml=”(Intranet)”


}


}


}


}


}