Tuesday, September 23, 2008
Create a folder inside your SHAREPOINT list or document library
{
try
{
using (rootWeb)
{
rootWeb.AllowUnsafeUpdates = true;
SPFolderCollection folders = rootWeb.GetFolder(eLibrary.RootFolder.ServerRelativeUrl).SubFolders;
SPFolder newFolder = folders.Add(strFolderName);
newFolder.Update();
eLibrary.Update();
}
}
catch(Exception ex)
{
Logger.LogWarning("Error configuring ELibrary Folder: " + ex.Message);
}
}
Wednesday, September 17, 2008
Create a SHAREPOINT site collection & subsites programatically
{
SPWebApplication webApplication = SPWebApplication.Lookup(new Uri("http://dev3:10131"));
SPSiteCollection siteCollections = webApplication.Sites;
siteCollections.Add("http://dev3:10131/IntranetMOSS", "chanaka_temp", "chanacse@gmail.com");
}
catch(Exception ex)
{
// log the error
}
// Add subsites into the siteCollection
try
{
using (SPSite mySite = new SPSite("http://dev3:10131/IntranetMOSS"))
{
using (SPWeb myWeb = mySite.OpenWeb())
{ //path name
SPWeb newWeb = myWeb.Webs.Add("SBU", "SBU's", "Add for commercial purpose", 1033, "STS#1", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("Newss", "News", "Update with the ", 1033, "STS#1", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("Groups", "Groups", "As a unit", 1033, "STS#1", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("CorporateNews", "Corporate News", "All you need", 1033, "STS#0", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("Services", "Services", "Always with you", 1033, "STS#0", false, false);
newWeb.Update();
newWeb = myWeb.Webs.Add("UserManuals", "User Manuals", "Help", 1033, "STS#0", false, false);
newWeb.Update();
}
}
}
// you can set the breadcrumb of the each site through the code also
// Simple task.........
try
{
SPSite ChildSite = new SPSite(web.Url);
SPWeb DChildWeb = ChildSite.OpenWeb();
SPNavigationNode ParentNode = new SPNavigationNode(parentWeb.Title, parentWeb.Url + "/HomePage.aspx", true);
SPNavigationNode ChildNode = new SPNavigationNode(DChildWeb.Title, DChildWeb.Title + "/HomePage.aspx");
parentWeb.Navigation.TopNavigationBar.AddAsLast(ChildNode);
web.Navigation.TopNavigationBar.AddAsFirst(ParentNode);
web.Navigation.UseShared = true;
web.Update();
}
catch (Exception ex)
{
// log this error
}
Create a webpart using Visual Studio
User can add a usercontrol & any code can be in your usercontrol
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace UCAddSubjectNewsWebpart
{
public class UCAddSubjectNews : WebPart
{
UserControl usercontrol;
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
usercontrol.RenderControl(writer);
}
protected override void CreateChildControls()
{
base.CreateChildControls();
this.Controls.Clear();
usercontrol=(UserControl)this.Page.LoadControl("~/usercontrols/Name_of_user_control.ascx");
this.Controls.Add(usercontrol);
}
}
}
Saturday, September 6, 2008
Install a feature into sharepoint
2) Navigate to 12 hive folder
a. cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
3) stsadm –o installfeature – name myFeature
4) Activate the feature by using the site settings --> site administration --> site features --> Click activate button of myFeature (new feature)
When you create a Document Management System
1) Types of document that we are going to store (upload)
2) Templates that we are going to use
3) Metadata that associated with the documents
4) Access control
5) Policy of the documents
6) Conversion of documents (if needed in future)
7) Ability to move documents away from the document library
Most of these features can be done by using the OOB features
1) Permission setting of the document libraries
2) Target audience of the document libraries
3) Select main type of the document that we are focusing on library
How to plan the document library
1) Define the roles
2) Estimate the usage of documents
3) Organize the document
4) Content types (metadata, features, properties)
5) Content control
6) Workflows
7) Policy management
Thursday, August 28, 2008
Add a flash material into sharepoint site
2) Then Add a content editor to the page
3) Click Source Editor
4) Add following Code
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
WIDTH="550" HEIGHT="400" id="myMovieName">
NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
Tuesday, August 26, 2008
Add users programmatically into a SHAREPOINT cutomlist(VERY RARE)
{
try
{
string[] strArrNames = pstrIDS.Split(new char[] { ';' });
string strSend = string.Empty;
SPWeb web = MySite.AllWebs[WebSite];
SPUserCollection MLUserGroup = web.SiteUsers;
for (int count = 0; count <>
{
string strusreName = MLUserGroup.GetByID(int.Parse(strArrNames[count])).Name;
strSend += strArrNames[count].Trim() + ";#" + strusreName + ";#";
}
return strSend;
}
catch
{
return string.Empty;
}
}
Wednesday, August 20, 2008
Active directory acces to get Telephone number
public Hashtable getUserTelephoneNumbers()
{
try
{
Hashtable arrNames = new Hashtable();
int count = 0;
string domain = "172.21.0.255";
DirectoryEntry de = new DirectoryEntry("LDAP://" + domain);
de.Username = "MS\\Administrator";
de.Password = "password";
DirectorySearcher ds = new DirectorySearcher(de);
ds.Filter = "(&(objectClass=user)(objectCategory=person))";
ds.Sort.Direction = System.DirectoryServices.SortDirection.Ascending;
ds.PageSize = 4000;
count++;
try
{
SortedList objSortedList = new SortedList();
foreach (SearchResult result in ds.FindAll())
{
DirectoryEntry deTemp = result.GetDirectoryEntry();
try
{
arrNames.Add(deTemp.Properties["cn"].Value.ToString(), deTemp.Properties["TelephoneNumber"].Value.ToString());
}
catch (Exception ex)
{
ex.Message.ToString();
}
}
}
catch (Exception ex)
{
//HttpContext.Current.Response.Write(ex.ToString());
}
finally
{
}
return arrNames;
}
catch
{
return null;
}
}
Get E-mails of all users in a SPGroup
SPWeb web = site.AllWebs
[ConfigurationManager.AppSettings["WEB_SITE"].ToString()];
SPGroup group = web.Groups[0];
SPUserCollection MLUserGroup = web.SiteUsers;
String strUserGroupName = MLUserGroup.GetByID(27).Groups[0].Name
Tuesday, August 5, 2008
CAML query with a filter between DateTime's
SPQuery query = new SPQuery();
query.Query = "<Where><And><Geq><FieldRef Name="Created" /><Value Type="DateTime" IncludeTimeValue='FALSE'>" + SPUtility.CreateISO8601DateTimeFromSystemDateTime(ddtStartDate) + "</Value></Geq>" +
"<Leq><FieldRef Name="Created" /><Value Type="DateTime" IncludeTimeValue='FALSE'>" +
SPUtility.CreateISO8601DateTimeFromSystemDateTime(ddtEndDate) + "</Value></Leq></And></Where>";
SPListItemCollection collection = list.GetItems(query);<Query>
<Where> <Eq> <FieldRef Name="CatalogItem" LookupValue="TRUE" /> <Value Type="Lookup">Value Goes Here</Value> </Eq> </Where> </Query> <where> <eq> <fieldref name="PersonFieldName"/> <value type="User">User Display Name</value> </eq> </where>
