SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
// Test to see if the site has unique permissions
if (web.HasUniqueRoleAssignments)
{
Response.Write(web.Title + " does not inherit permissions
" );
}
else
{
Response.Write(web.Title + " inherits permissions
" );
}
Tuesday, January 13, 2009
Monday, January 12, 2009
Uncustomized and Customized Pages
Ghosted - Uncustomized
Unghosted - Customized
In WSS v3 pages exist in one of two states: customized or uncustomized. An uncustomized page is one that is listed in the site's contents database, but the actual source of the page (the file) resides on the file system, and the content database simply contains a link pointing to the file. A customized page is also listed in the content database, but the source of the page is also stored in the database. Future requests for that page (in the context of a specific site) will be served from the database, not from the file system.
Unghosted - Customized
In WSS v3 pages exist in one of two states: customized or uncustomized. An uncustomized page is one that is listed in the site's contents database, but the actual source of the page (the file) resides on the file system, and the content database simply contains a link pointing to the file. A customized page is also listed in the content database, but the source of the page is also stored in the database. Future requests for that page (in the context of a specific site) will be served from the database, not from the file system.
Saturday, January 10, 2009
SharePoint Development using C#
Before you start developing you need a reference to "using Microsoft.SharePoint;" namespace.
Working with a list
Short description of some classes:
Site Organization Classes
SPContext -
SPWebCollection -
SPListCollection -
SPWeb - represents site;
SPSite - represents site collection;
SPList -
List Classes
SPField -
SPView -
SPListItem -
Getting the Current Website
SPWeb web = SPContext.Current.Web;
Site Collection Navigation
SPSite siteCollection = SPContext.Current.Site;
SPWeb rootWeb = siteCollection.RootWeb;
TreeNode rootNode = new TreeNode(rootWeb.Title);
treeSiteCollection.Nodes.Add(rootNode);
addSubWebsToTree(rootWeb, rootNode);
Create a list
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
SPList list;
try
{
list = web.Lists["Student Assignments"];
}
catch(Exception ex)
{
System.Guid listID
= web.Lists.Add("Student Assignments", "", SPListTemplateType.Tasks);
list = web.Lists[listID];
}
Creating a column in a list
SPFieldCollection fields = list.Fields;
SPField gradeField;
if (fields.ContainsField("Grade"))
{
gradeField = fields["Grade"];
}
else
{
fields.Add("Grade", SPFieldType.Number, false);
}
Adding Field to default view of the list
SPView defaultView = list.DefaultView;
if (!defaultView.ViewFields.Exists("Grade"))
{
defaultView.ViewFields.Add("Grade");
defaultView.Update();
}
Creating a new list item
SPListItemCollection items = list.Items;
SPListItem newItem = items.Add();
newItem["Title"] = "Homework 1";
newItem["DueDate"] = System.DateTime.Now;
newItem["Grade"] = 5; newItem.Update();
Working with a list
Short description of some classes:
Site Organization Classes
SPContext -
SPWebCollection -
SPListCollection -
SPWeb - represents site;
SPSite - represents site collection;
SPList -
List Classes
SPField -
SPView -
SPListItem -
Getting the Current Website
SPWeb web = SPContext.Current.Web;
Site Collection Navigation
SPSite siteCollection = SPContext.Current.Site;
SPWeb rootWeb = siteCollection.RootWeb;
TreeNode rootNode = new TreeNode(rootWeb.Title);
treeSiteCollection.Nodes.Add(rootNode);
addSubWebsToTree(rootWeb, rootNode);
Create a list
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
SPList list;
try
{
list = web.Lists["Student Assignments"];
}
catch(Exception ex)
{
System.Guid listID
= web.Lists.Add("Student Assignments", "", SPListTemplateType.Tasks);
list = web.Lists[listID];
}
Creating a column in a list
SPFieldCollection fields = list.Fields;
SPField gradeField;
if (fields.ContainsField("Grade"))
{
gradeField = fields["Grade"];
}
else
{
fields.Add("Grade", SPFieldType.Number, false);
}
Adding Field to default view of the list
SPView defaultView = list.DefaultView;
if (!defaultView.ViewFields.Exists("Grade"))
{
defaultView.ViewFields.Add("Grade");
defaultView.Update();
}
Creating a new list item
SPListItemCollection items = list.Items;
SPListItem newItem = items.Add();
newItem["Title"] = "Homework 1";
newItem["DueDate"] = System.DateTime.Now;
newItem["Grade"] = 5; newItem.Update();
Subscribe to:
Posts (Atom)