Sharepoint 2007 – Templates and Definitions

Similarly to SPS 2003 / WSS 2, Sharepoint 2007 (MOSS and WSS 3) has both templates and definitions. Note that the end user is not aware of the difference between templates and definitions – they are both effectively sharepoint sites.

are the core definition of what a site is (they are contained in folders with many markup files), are stored in 12\Template\1033. Note that Sharepoint 2007 will be compatitible with Sharepoint 2003 definitions.

As per Sharepoint 2003, templates (.stp files) contain the differences between the site template that has been created and a definition that they extend. These are effectively cab files that are stored in the content db and can be create by an end user. It should be noted that sharepoint 2003 templates are not compatible with sharepoint 2007 (unless, possible, that the sharepoint 2003 definition on which they are based has been exported over to the Sharepoint 2007 deployment.

Note that Features are a totally new addition to Sharepoint 2007 – these extend definitions. I plan to write a seperate article discussing the ins and outs of these.

Simulating framesets

This is a really cool thread i found on simulating a frameset with divs and javascript. This is particularly useful when you dont want to force the reloading of the entire frame (but without having control over the frames content and links, and dont want to have to use the base tag in a frameset

Also, how to get rid of the IE vertical scrollbar Basically just set margin: 0; and overflow:auto; for the body css tag.

Note that I have only tested these out in IE, and have not checked for cross browser compatibility or w3c compliance.

Microsoft Expression

I have just seen the Microsoft expression suite – I am pretty keen to get my hands on them (especially sparkle, when used for developing interfaces for windows apps).

Acrylic Graphic Designer – I guess that this is equivalent to Photoshop

Quartz Web Designer – This seems to offer functionality similar to the Macromedia suite and I guess would fill the space left by frontpage (which is becoming SharePoint Designer) and offer more professional functionality.

Sparkle Interactive Designer – This product really excites me – it seems to be the primary tool now used to create interfaces for windows programs (it has also been rumoured that you will be able to also create web interfaces – rumoured to compete with flash – i wonder whether this is where the microsoft ajax suite, Atlas, will fit in with this?).

Windows Presentation Foundation WPF (not part of the expression suite)
I believe that Sparkle will be the primary tool for designing this.

Formerly known Avalon, is Microsofts unified presentation layer for Windows and is exposed through WinFX, (vistas managed-code programming model that extends the Microsoft .NET Framework. WPF consists of a display engine and an extensible set of managed classes that development teams can use to create apps. WPF also introduces Extensible Application Markup Language (XAML), which enables developers and designers to use an XML-based model to declaratively specify the desired user interface (UI) behaviour.


Sharepoint: AlternateHeader cannot be unset

Today I had a bit of a nightmare when trying to ensure that the AlternateHeader of a web was set to blank (it had previously had a custom header applied). Unfortunately I could not find a simple solution to this, and unfortunately had to resort to altering the sharepoint db (this is not recommended / supported by Microsoft).

The following code does not behave as expected:

currentWeb.AlternateHeader = "";

It would appear that when the AlternateHeader is set (as above), the stored proc “proc_UpdateTpWebMetaData” is called (in the xx_SITE database). This contains the following check:

AlternateHeaderUrl = CASE WHEN @AlternateHeaderUrl IS NULL THEN AlternateHeaderUrl ELSE @AlternateHeaderUrl END,

There are two solutions to the issue:

The first one is too modify the stored proc, removing the check – i.e. AlternateHeaderUrl = @AlternateHeaderUrl END, (note that I am not sure what implications this may have on other areas of the code).

The second solution is to simply edit the webs table in the sharepoint xx_SITE database. Simply select the relevant list item in enterprise manager and reset its AlternateHeader value.

Sending emails with

Sending emails with was actually surprisingly easy (note that I only tested it on an form in Server 2003). Adding attachments etc was also surprisingly easy (no need to worry about mime boundaries etc).
The machine that the application is running on must be running an SMTP service (this can be set up with the Server Configuration Wizard). Once this is set up, you must allow relay access from localhost…

  1. Go to: start > settings > control panel > Administrative Tools > Internet Information Services
  2. Expand the ” (local computer)” node
  3. Right click on your SMTP server > go to “Properties”
  4. Click “Access” tab
  5. Under Relay Restrictions, click the “Relay” button
  6. Click “Add”
  7. Select “Single Computer” and enter IP address
  8. Hit OK, OK, OK (until the properties dialog is closed)

Actually Sending Emails
Add “using System.Web.Mail;” to the top of the relevant file

MailMessage mail = new MailMessage();
mail.To = "";
mail.From = "";
mail.Subject = "Contact from website";
mail.Body = "Email body";
SmtpMail.SmtpServer = "localhost";

I wont go on too much about sending attachments – its all pretty well explained at
Stop press – sending with .net 2
If you are using windows SMTP be sure that any line ending characters in the message are of the form \r\n and not just \n. I have had issues in the past with relay servers failing to send wrongly formatted line endings. Apparently 822bis (not sure what this is) specifically prohibits other uses of LF.

Some rough notes on the Global Assembly Cache (GAC)

The GAC is essentially visible as a special folder, normally residing at C:\Windows\Assembly. It can only contain assemblies, and these assemblies must be strongly named. The assemblies within the gac are essentially dlls that can be used by all applications on the computer – note that the various .net assemblies appear in the gac – e.g. system.text.

Note that assemblies dragged and drop into the gac folder are only referenced by the gac, the actual assemblies still reside in their original location. To actually copy an assembly to the gac, you must use gacutil.

A strong named assembly is one that has been signed via a public key (part of a keypair). A keypair can be generated with the strongly naming tool (that comes with visual studio / .net). Note that you can assign an assembly when built (providing you have a keypair) – by specifying certain attributes in the projects assemblyinfo.cs file. Once an assembly has been strongly named, you can simply copy it to the gac location – it will then be available to all applications.

[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("C:\path\to\publickey")]
[assembly: AssemblyKeyName("The.Key.Name")]

Note that delay sign means that the assembly can be signed later (if say only an administrator, not a developer has access to the relevant private key / certificate.

Also note that if you just strongnaming an assembly, you don’t need to distribute a public key or similar.

Also note that assemblies in the gac cannot be reference in visual studio (or at least easily – without editing registry keys etc). Instead, you must reference a copy of the relevant dll locally (so the dll should exist locally). Note that once the relevant project using that reference is build, you no longer need the dll locally if it resides in the gac. This is because assemblies are searched by fusion.dll runs (which controls the gac). This looks in the gac for an assembly before it looks locally.

Some links…

Note that these notes are very rough atm, i will hopefully tidy them up and add more info at some point.

Search Engine Optimisation Notes

Search engine optimisation. Although the main search engines are continually tweaking their ranking algorithms, by following a few principles can ensure that your site features as highly as possible in search engine results. This documents is a set of rough notes on how to ensure your site gets the highest possible rankings with search engines.

  • Google normally picks up your site when other sites link to it, however you can submit your site using this page…
  • Ensure that no robots.txt or meta robots tags restrict spiders from parts of a site that you want indexed
  • Google page rankings have recently been altered, so that links from directories and adverts are greatly reduced in importance (eg froogle etc)
  • Make sure the body text of the site contains keywords and phrasing that you want your site to appear under (at about 5-10% keywords in copy)
  • Submit your site to the dmoz directory (used by yahoo and google). Dmoz (also known as the open directory project) is a directory that is manually maintained by administrators, who maintain the quality of links etc, instead of being created by bots (like most other directories). Google seems to rank links from this highly (as it is a pet project related to google). Please note that as the directory is edited and updated by people, it can take in excess of several months to get listed.
  • Make sure as many people link to you as possible. Recipricate links (google rates such links higher) This is one the single most important thing it getting a good search engine ranking. The page rank of the sites that link to you is also important. Note that also rates the speed at which your site gains links and the link life span. The anchor text of each link is also important and should contain keywords that you expect people to search for (no more than 5-10 words though). Links must be grown slowly – google assumes sites that are suddenly linked by 100’s of other sites are spammers.
  • Meta keyword tags are not really used by any search engines now, however it is good practice to ensure that you have them. These should also not be excessively long. The meta description of the site must also be added as this is what is shown by a lot of search engine in search results.
  • make sure that the title tag is set and is relevant to the pages
  • Ensure that the site has logical clear structure, with h1’s h2’s etc. To many levels of nesting (eg if your using tables) can adversely affect your search listings. If possible use divs for positioning and only use tables for tabular data.
  • Google seems to look at the ip address of the server that your site is listed on, hence google will not rate highly links to other sites on that server.
  • Google also seems to look at how long a domain has been registered for. Domains registered for 1 year are generally typical of spammer sites etc, so register your domain for more than 1 year.
  • Google ranks sites that have been established longer higher. So the older your site, the higher the potential ranking.
  • Google adversely rates multiple domain names pointing at one site, and may even block sites from its listings that do this excessively.
  • Click through rates, caches of client browser are also monitor via the google toolbar, hence sites
  • Google adversely looks upon sites that have hidden text eg. by display=none in the style sheet. It assumes that sites doing this have been coded to trick google into ranking it for words that are not scene by the user. Google is also becoming more advance on its detection of text hiding tricks.
  • Update text regularly, google seems to notice the positioning of keywords within the text, so alter accordingly

Please note that google can take a few months before your site appears stable within listings. Only the homepage is initially shown in the google rankings.
For information on how google indexes, see
Google algorithm details
Search engine watch
Search engine world
SEO chat

Debugging Javascript with Visual Studio 2003

To break into the debugger from a JavaScript file enter the keyword “debugger” at the location you want to break into the debugger at. Note that this will prompt you to select your choice of debugger – choose visual studio and then walk through the events / and view watches as you would when debugging the CLR.
Note that when the debugger starts, make sure you set it to debug “scripts” (where you normally select common language runtime).

Note that due to javascript being an interpreted, no program debug database is create, so you cannot debug uses the breakpoints (as with the CLR code – eg C#). Even though it appears that you can set breakpoints, these are not fired. Instead you must insert the “debugger” keyword into the relevant javascript.

In IE – to trigger debugging when there is an error in the executing javascript, tools -> internet options -> advanced tab, and uncheck “disable script debugging” – you may need to uncheck two successive checkboxes. Note that when an error is hit, you will be prompted to debug in visual studio. Note that when doing this, you may be asked to selected the type of code you wish to debug – if so, always select “script” when debugging javascript.

Web developer toolbars (not entirely to js debugging)…
Firefox web developer toolbar
IE web developer toolbar