Monthly Archives: November 2010

Chapter 2: Overview of New Features in SharePoint 2010

Browser support for SharePoint 2010: Supported, Supported with known limitations and Not Tested

IE 6 is not supported.

All CSS style sheets are in this folder:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\STYLES

each control in SharePoint 2010 is responsible for requesting which CSS it needs to render properly; therefore, depending on which controls are on the page, you might see a different combination of CSS fi les being referenced.

SharePoint:SPShortcutIcon: Sets the favicon in the top left of the browser URL bar
SharePoint:CssRegistration After=”corev4.css”: Tells SharePoint what to load after Corev4 css

For example:
< SharePoint:CSSRegistration Name=”3.css” After=”2.css”

SharePoint:SPRibbon: Adds the Fluent UI (the ribbon) to the page
SharePoint:PopoutMenu: Adds the breadcrumb that, when clicked, shows the pop-out that displays your current location in the site in a hierarchical tree structure

SharePoint:DeveloperDashboard:
Loads the actual developer dashboard at the bottom of the master page This is hidden until the launcher is clicked

SPSWC: MySiteCssRegistration: Allows the use of specific CSS

THEME:

.thmx
Open XML fi le format, which is already used by Office programs like Word 2007 and PowerPoint 2007 to create themes. Users create a new theme by selecting 12 colors and two fonts

You can create new theme from Word 2010 or Powerpoint 2010 and import into Sharepoint 2010.

WIKI Page

Good for creaing knowledge base pages. Collaboration Portal (wiki in MOSS 2007) has been replaced by Corporate Wiki in Sharepoint 2010. Biggest difference – Enterprise Wiki uses page layouts for content, while team site uses text layout

Team site – use 8 different text layouts, not possible to create new text layout.
Or, you need to enable Publising Feature which uses payge layout, and cab eb customized.

Basically, text layout and page layoout are te same…… both used to format the text/image layout in a page.

SharePoint 2010 has its own client object model that allows Silverlight or JavaScript to easily access SharePoint data. This new object model provides a simple API to add, retrieve, update, and manage data in SharePoint using code that does not require any compiled code. Administrators will be excited that their servers wont be cluttered with countless custom DLLs in the GAC.

Support for media has also been added to the Content Query Web Part (CQWP), which provides a way to dynamically serve up media based on the filter criteria set in the Web Part. The CQWP also supports the capability to stream content, as opposed to waiting for the entire content to download before it is displayed to users — a big change from how media was handled in SharePoint 2007.

Usage Analytics – Sharepoint Logging Database

Mater Page

Application Page (under _layouts) uses a dynamic master page on a per-site basis. A good example is the Site settings (settings.aspx) page. If an error occurs in the master page used by application pages, Sharepoint will fall back to the defaul v4.master.

Chapter 1: What is Sharepoint Branding?

Wrox SharePointR 2010 Branding and User Interface Design

Branding for SharePoint includes the creation of master pages, page layouts, Cascading Style Sheets (CSS), Web Parts, and eXtensible Stylesheet Language Transformations (XSLT).

Technically speaking, themes can be thought of as changes that are applied to the existing look and feel through the use of CSS. In SharePoint 2010, themes are created with the Microsoft Office client software (2007 and above), using either Word or PowerPoint to create .THMX files
that describe the 12 theme colors and two fonts available in the new SharePoint themes. Once created with Office, they can be loaded into SharePoint 2010 and applied to any site by site owners. Server version of SharePoint 2010 enables site owners to modify the themes — i.e., the colors and fonts — directly in the SharePoint Web user interface

Theme – comparable to paint the wall

Master page – comparable to alter the physical structure of the house

SharePoint comes with a few out-of-the-box master pages that can be used for website branding right away:

(1) v4.master: default master page that is used for many of the site templates
(2) nightandday.master: accessible only in a SharePoint Server 2010 site that has the Publishing Feature enabled.

(3) minimal.master: this master page is not intended to be the starting point for branding, as it lacks several common SharePoint controls.

3 main types of content pages:

(1) Publishing pages
(2) Web part pages
(3) Wiki pages

Publishing pages:

Publishing pages are available only in SharePoint Server 2010 on sites where the Publishing Feature is enabled. The Publishing Feature enables authors to (1) create pages that have an approval workflow so that (2) content can be reviewed and approved before being published.

Publishing pages are created by using page templates called page layouts. If master pages create the outer shell of a SharePoint page, then page layouts define the body of a page. They enable content authors to create pages that contain text, HTML, graphics, rich media, and more.

Several out-of-the-box page layouts can be used right away in a SharePoint Server site, but also remember that designers and developers can always create their own custom page layouts.

The function of Web Part pages is fairly obvious by their name. They are pages that contain Web Part zones.

The word “wiki” is Hawaiian for quick. Wikis are a great way to collaborate with others on a project. They are also very useful for creating knowledge bases or other repositories for storing and sharing information.

CSS


CSS is pervasive in SharePoint branding. Almost every aspect of SharePoint is styled by CSS. All the SharePoint controls that are loaded by a master page are styled by CSS, as well as many Web Parts — even SharePoint themes apply to specially commented CSS fi les in SharePoint 2010. Because of the importance of CSS in SharePoint, a sound understanding of it is crucial to becoming skilled at branding in SharePoint.

CSS is longer just a designer’s tool! As a developer you need to be familiar with it too.

Unlike SharePoint 2007, which had essentially one large core CSS file that was loaded for each page, SharePoint 2010 splits its default CSS across several smaller CSS files that are loaded according to what controls are available on a given page; however, much of the main CSS for SharePoint still resides in one core CSS fi le named corev4.css.

Important: The intent of this new division of labor is to load only the CSS that’s necessary
to render a given page.

70-668 in Feb/March

The next exam is coming in Feb/March 2011…. Exam 70-668: PRO: Microsoft SharePoint 2010, Administrator. I heard that it is easier than 70-573 as it is mainly about administration and configuring and powershell stuff.

http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-668&locale=en-us

I started working on the subject recently by studying some ebooks realted to Sharepoint administration. I was so used to printed books in the past but starting from a few months ago I  really enjoy the benefits of reading ebooks. Less cost (or free sometimes), portable, easy access to code samples etc. I have two 22′ flat screen PC monitors sitting side by side at home so it makes it even easier for me to take notes while studying ebooks.

Still, I believe the materials in MSDN library are the most important of all….. good test preparation materals don’t necessarily cost money.

Windows Event Logs and Logging Database

Event throttling: If you enable event log throttling, SharePoint will not repeatedly write the same event to the Windows logs if there is a problem. Instead, it will only write events periodically, telling you the event is still being throttled. This keeps your Windows Event Logs from being overrun by the same message. In Sharepoint admin, this is called Event Log Flood Protection

Logging database: collecting health data – this is enabled by default. To configure it:

Logging database are very similar to trace logs: (1) by default htye’re saved in the same LOGS folder:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS\ and (2) same file name but with the extension of “*.usage”.

Timer Jobs

At the most basic level, timer jobs are tasks defined in XML files in the configuration database. Those XML files are pushed out to the members of the farm, and are executed by the Windows service, “SharePoint 2010 Timer.”

in Central Admin à Application management à Manage Content Database, you can select the server on which the timer jobs will be run. Two purposes: (1) Easier for trouble shooting; (2) move the timer job burdon to a server that has a lighter traffic.

ULS Logging – Part 2

A better way is to use Get-SPLogEvent’s -StartTime parameter to limit the events it reads. The following command returns the last ten events in the last five minutes:

Get-SPLogEvent -StartTime (get-date).addminutes(-5) | Select -Last 10

In most cases, when you use Get-SPLogEvent, it will be to get all of the events for a particular correlation ID.

Get-SPLogEvent -StartTime (Get-Date).addminutes(-10) | Where-Object {$_.correlation -eq “00000000-0000-0000-0000-000000000000”}

With this method you can quickly get the log event entries that you’re looking for.

New-SPLogFile: tells SharePoint to close out the current log file and create a new one.

Merge-SPLogFile: merge the trace logs from all of the SharePoint servers in your farm into one log file. By default, Merge-SPLogFile only merges events from the last hour
from each machine
. You can use –StartTime, -EndTime
to customize the tiem range. it creates a timer job on all of the machines in the farm. This timer job collects the logs requested, and then copies them over to the server where Merge-SPLogFile is running.


Syntax: Merge-SPLogFile –Path farm.log

Syntax: Merge-SPLogFile –Path farm.log –Correlation “9ed2h-d94-234123fdf-234e-asfasdfds”

This will only merge the log entries that belong to this Correlation ID.

Good for (1) troublshoorting, and also for (2) archiving log files.

ULS Logging – Part 1

Notes from studying Wrox – Real World Sharepoint 2010

Chapter 3 – Monitoring Sharepoint 2010

Unifi ed Logging Service (ULS) is the service responsible for keeping an eye on SharePoint and reporting what it fi nds. It can report events to three different locations: (1) Sharepoint Trace Logs (2) Windows Event Log and (3) Sharepoint logging database

(1) Sharepoint logs: They are plain old text files that are tab delimited and can be opened with any tool that can open text files. By default, this is the log location:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS

By default, a new log file is created every 30 minutes. But you can change it using PowerShell: with the set-SPDiagnosticConfig –LogCutInterval 60 command to change to 60 minutes.

SP 2010 file is much cleaner than SP 2007 log file, yet provide more info; SP 2010 perform file compression to log files to save space. With the SP 2010, you have better control over which events to log; and you can set it back to the original setting once issues is resolved. This is where to configure it: in Centeral Admin à Monitoring à Configure Diagnoctic Logging.

There are 20 categories to choose from; you can choose individual categories or subcategories to monitor. For some reason I can’t save the categories/subcategories on this page.

OK, I found out why – you have the use the category/subcategory checkboxes together with these two drop downs. In other words, select the categoryies/subcategories, and then select from the drop down as to how you want to log the selected items. Once you click OK, the changed categories/subcategories will become bold, so you know what has been changed compared to the original setting.

You can also change the location of log files. Remember this is a FARM LEVEl setting, not server setting. So all servers will be affected!!! Make sure the drive letter exists for each server
before you change the location.

Every Sharepoint 2010 Administrator should get cozy with Windows PowerShell.

Get-SPDiagnosticConfig: retrieve the diagnostic settings in your farm
Set-SPDiagnosticConfig: change them

Use Get-Help
to get help on a cmdlet

Change log file location – Set-SPDiagnosticConfig -LogLocation e:\Logs

You can get a list of the cmdlets that deal with the log levels by running the command Get-Command -Noun SPLogLevel in a SharePoint Management Shell. Search any command that has the keyword “SPLogLevel” in it.

This command lists all log levels of a specific category
Get-SPLogLevel | Where-Object {$_.area.tostring() -eq “Access Services”}

The -Identity parameter of Get-SPLogLevel corresponds to the second column (or Name column)

The Clear-SPLogLevel
cmdlet clears out any changes you have made, and sets the logging levels to their default values for both trace and event logging.

Correlation ID

The

correlation ID is a globally unique identifier GUID that is assigned to each conversation a user or process has with SharePoint. Each entry in the trace logs has a correlation ID, you can just open up the trace log in

Notepad and look for the lines that reference this conversation. The correlation ID is considered by many administrators to be one of the best new features in SharePoint 2010.

You can also use Developer Dashboard to get the CorrelationID.


To view developer dashboard:
(1) The user browsingthe page must have the AddAndCustomizePages permission (site collection admins and users in the Owner group, by default)
(2) it must be enabled in your farm

By default, it is OFF.

Powershell to turn it on/off/on demand:

$dash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;

$dash.DisplayLevel = ‘OnDemand’;

# $dash.DisplayLevel = ‘Off’;

# $dash.DisplayLevel = ‘On’;

$dash.TraceEnabled = $true;

$dash.Update()


How to view/handle log files?

(1) Excel
(2) MSDN ULS Viewer –

Sharepoint SPPersistedObject Class

http://www.codegain.com/articles/sharepoint/developmentprogramming/introduction-of-sppersistedobject-class-in-sharepoint.aspx

1. This class is inside namespace Microsoft.SharePoint.Administration

2. This is base class for all administration objects.
3. It serializes
all fields marked with Persisted attribute to XML.

4. It writes XML BLOB to configuration database.
5. Configuration data that is stored in persisted object is automatically made available to every process on every server in the farm
—————————————————————————-
How to use SpersistedObject —

  1. Create your application that does something. You need a place to store the user id and password. So you decide to use SPPersistedObject
  2. Create a class (say, Counter.cs) that inherits from SPPersistedObject. Define your name and password name in the class.

  3. Then in your app code (created in Step 1), when you need to store/restrieve name/password, you can create a Counter class and use it to save data:

    counter.id is a GUID

  4. To retrieve the name/password, do this:

Lookup Column in a Custom List

A lookup column is a column in a Custom List that will populate itself with values from a column from another list.

e.g., “All Movies” is a list with 5 movies names (in “Title” column).

Now you want to create another list, and specify every your family member’s favoriate movie (movies from “All Movies” list). So create a new costum list call “Family Favorite Movie”. Use the “Title” column to enter family member’s name, and create a new lookup column (Column anme: “Favorite Movie”), and get its value from the “Title” column of the “All Movies” list.


Click OK to create a list. Once done, you can add a new item in “Family Favorite Movie”, and this is what you see – the “Favorite Movie” field is a drop down list, populated from “All Movies”.


 
 

  

Sandbox Solution (2)

http://msdn.microsoft.com/en-us/magazine/ee335711.aspx

Building a Sandbox Web Part

A sandboxed solution looks and behaves like a farm solution, but a sandboxed solution’s assembly must be marked to allow partially trusted callers.

Remember that a sandboxed solution can be deployed as a full-trust solution and gain the expanded capabilities that come with running in full trust because nothing in the .wsp solution file specifies it as a sandboxed solution or a farm solution. This is determined by how the solution is deployed.

Create a empty Sharepoint project, called testWebPart, sandbox solution. Add a web part to the project, default name WebPart1. Your web part is ready to deploy. VS deploys and activates the solutions in the Solution Gallery if you press F5.

*** As you can with other types of Visual Studio projects, you can set a breakpoint in the code for a sandboxed solution. However, Visual Studio won’t recognize a breakpoint at this point because the Web Part has not been added to a page. You’ll see an empty red circle in the left margin for the line of code that has the breakpoint, as shown in Figure 5, indicating that the assembly that contains the Web Part has not been loaded in the attached process. When you add the Web Part to a page, Visual Studio detects that the assembly has been loaded and will stop on the breakpoint.

Full-trust solutions run under the IIS worker process used by SharePoint called w3wp.exe. However, sandbox solution doesn’t. They run under the sandboxed worker process called SPUCWorkerProcess.exe. (VS attomatically attach the debugger to this process when you press F5)

Full trust solution – w3wp.exe
Sandbox solution – SPUCWorkerProcess.exe

If you’re debugging a solution that’s already deployed, you need to manually attach to this process. In VS 2010, Debug à Attach to Process


Examples —

Add the code to CreateChildControls method in the web part.

protected override void CreateChildControls()

{

base.CreateChildControls();

Label ListCount = new Label();

ListCount.Text =

String.Format(“There are {0} Lists”,

SPContext.Current.Web.Lists.Count);

Controls.Add(ListCount);

}

Build, deploy and add the web part to your web page, you should see this:

Now instead of inserting the above code, insert this now:

protected override void CreateChildControls()

{

base.CreateChildControls();

SPSecurity.RunWithElevatedPrivileges(

delegate

{

Label ListCount = new Label();

ListCount.Text =

String.Format(“There are {0} Lists”,

SPContext.Current.Web.Lists.Count);

Controls.Add(ListCount);

});

}

Deploy and refresh the page again, you will get an security error because SPSecurity class is not part of the sandboxed SharePoint API. Visual Studio compiles against the full version of the SharePoint API, but at runtime, SharePoint swaps out the full API for the sandboxed API, and this API is what your code runs against. Visual Studio can help you write valid code by filtering IntelliSense for you when you create a sandboxed solution.

(CONTINUED IN Sandbox (3))

Store and Retrieve Configutation Data

http://msdn.microsoft.com/en-us/library/ff647766.aspx

Property Bag

A property bag enables you to add and retrieve properties to objects. Property bags are implemented as a simple hash table of property names and values. Do not attempt to store anything in property bags unless you are sure it can be serialized. Property bag can be accessed with the Properties property of an instance of the SPWeb class. If you want to store list-level configuration data, use the property bag of the root folder of the list.

SPFarm – Properties (SPPersistedObject)
SPWebApplication – Properties (SPPersisitedObject)
SPSite – AllProperties
SPWeb – AllProperties
SPList – RootFolder.Properties

Lists

*** Use list to store configuration data that end users can edit. Otherwise, consider using properties bag.

Here is an example to get a property from a web application property bag —

http://www.fivenumber.com/understanding-sharepoint-property-bag-settings/

Add property in SPFarm level

View property in SPFarm level

Add/Retrieve SPSite Proerty

Add/Retrieve SPWeb Property

You can also use Element.xml to save to property bag.