Joel's SharePoint Architect Blog

SharePoint 2010, MOSS & WSS Tips and Consultancy Tales

Subscribe Subscribe  View Joel Jeffery's profile on LinkedIn
joelblogs.co.uk | joelj.co.uk | joeljeffery.co.uk | jfdiphoenix.co.uk

Posts Tagged ‘SharePoint Developer’

I’ve created a set of (currently) 43 exam questions in an online practice paper that simulates the 70-573 exam – SharePoint 2010 Application Development.

These questions are all original – and a lot of hard work! Please, please do not distribute them in any format.

You can access them online, for free, here: Practice Exam 70-573 SharePoint 2010 Application Development

Although, all donations gratefully received! Smile

Technorati Tags: Development, Exams, SharePoint 2010, SharePoint 2010 Training, SharePoint Developer, SharePoint Training

I’ve finally created some practice tests of my own.

I’ve built an exam of 40 questions in a similar style to those from Microsoft 70-573 “TS: Microsoft SharePoint 2010, Application Development”.

These are brand new questions. Not pirated. Not copied. Not stolen.

Ethical.

And you can access them for free!

See the SharePoint Practice Exams page for more details and links to PayPal.

Technorati Tags: Certification, SharePoint 2010, SharePoint 2010 Training, SharePoint Developer

Event Receivers and Content Deployment Jobs

SharePoint 2010 has many wonderful improvements over previous versions. One of which is a vastly improved Content Deployment mechanism and API.

If your application makes use of Event Receivers or Feature Receivers, these can, depending upon what they do, cause problems during a Content Deployment job. If you have code that you’d rather not execute when your event is triggered as a side effect of a Content Deployment job, you can use the SPImportContext object to find out if a job is running, and if so, to take alternative action.

Here’s an example on an ItemAdding Event Receiver (you’ll also need a using statement referring to the Microsoft.SharePoint.Deployment namespace)

   1: /// <summary>

   2: /// An item is being added.

   3: /// </summary>

   4: public override void ItemAdding(SPItemEventProperties properties)

   5: {

   6:     if (!SPImportContext.Current.IsRunning)

   7:     {

   8:         //TODO: add event receiver code here

   9:         base.ItemAdding(properties);

  10:     }

  11: }

If you miss this out this check in an Event Receiver or Feature Receiver, you might cause deadlocks or spurious List Items that you did not intend.

Technorati Tags: Development, SharePoint 2010, SharePoint Architecture, SharePoint Developer

Time to burst another popular misconception.

SharePoint 2010 comes with a new server tag to help you set a Favourite Icon (FavIcon) for pages in your site. This is the <SharePoint:SPShortCutIcon> tag. The SPShortCutIcon tag lets you specify an IconUrl property. If we don’t mind hard coding our IconUrls, we can set it to something like:

<SharePoint:SPShortCutIcon IconUrl=”/Site Assets/favicon.ico” runat=”server” />

However, if you have many sites in a hierarchy, or many site collections, you might not want to have this hard coded.

SharePoint helps us out here with a handy thing called the SPUrlExpressionBuilder class. We can use the special server-side tag $SPUrl to format up Url strings that are relative to the current site or site collection.

If I wanted to use this technique with a related part of the page, the Site Logo Image <SharePoint:SiteLogoImage>, I could embed the following code into my master page:

<SharePoint:SiteLogoImage LogoImageUrl=”<% $SPUrl:~sitecollection/SiteAssets/icon.png%>” runat=”server”/>

It would be nice to use the same technique with FavIcons. Indeed, there are are a lot of blog sites that suggest this is possible. I’ve tried this out, and I have no idea how it could work.

The reason the above code works is that SPSiteLogoImage.LogoImageUrl is a System.String type. $SPUrl statements return a System.String. No problem there.

However, SPShortCutIcon.IconUrl seems to have broken this pattern, and is actually a System.Uri. Any attempt to use $SPUrl to format a relative Url results in a casting error from System.String to System.Uri.

Unable to cast object of type 'System.String' to type 'System.Uri'

Good news is, there is a workaround. It’s not pretty, but we can use $SPUrl to set the System.String value of the Text property on an asp:Literal control.

We then need to sandwich that in between two more asp:Literals to render a complete client-side <link rel=”shortcut icon” …/> tag.

<asp:literal runat=”server” Text=”&lt;link rel=’shortcut icon’ href=’” /><asp:literal runat=”server” Text=”<% $SPUrl:~sitecollection/Site%20Assets/favicon.ico %>” /><asp:literal runat=”server” Text=”‘ type=’image/vnd.microsoft.icon’ /&gt;” />

I told you it wasn’t pretty, but at least we didn’t have to write any custom controls of our own. Here’s the HTML it outputs:

<link rel=’shortcut icon’ href=’/Site%20Assets/favicon.ico’ type=’image/vnd.microsoft.icon’ />

If anyone has a more elegant (read: less kludgy) solution to the problem, please post a comment!

Post Script:

Here’s a nicer solution from one of our readers: (Many thanks, Adam!)

<link rel=’shortcut icon’ href=’<% $SPUrl:~SiteCollection/Style Library/Images/favicon.ico %>’ />

 

Technorati Tags: SharePoint Designer 2010, SharePoint Developer

About Me

Hi, and Welcome to my .NET and SharePoint Architecture Blog!

I’m a Microsoft Certified Trainer, a SharePoint Architect and a large scale Microsoft .NET implementation expert. I’m also a trained Enterprise Architect and experienced practitioner of Technical Due Diligence projects. I’ve recently started a series of video podcasts on SharePoint 2010. You can find links to them on this blog site, and also at iTunes (search for “joelblogs tv”).

I run a Microsoft Gold Certified Partner in the UK called JFDI Phoenix Ltd, and you can find us here: http://www.jfdiphoenix.co.uk.

Feel free to view my
View Joel Jeffery's profile on LinkedIn

Or drop me a line with the contact form below!

Technorati Tags: SharePoint Administrator, SharePoint Architect, SharePoint Developer