Skip to main content

Sharing is Caring

Go Search
Home
  

Announcing: Community Kit for SharePoint: Development Tools Edition (CKS:DEV)
Happy Holidays!
Quick Deploy in SPVSX: Part One - Background and Approach
Announcing: SPVSX – SharePoint 2010 Visual Studio Extensions
The DebugApp trick for Productive SharePoint Development: Part 1
'Ello Guvners!
Speaking at Christchurch SharePoint User Group, this Tuesday!
Blog Hiatus, OE, and The Meaning Of Life
I'm A SharePoint Server MVP
Happy Christmas and a Merry New Year
Sharing is Caring > Categories
SharePoint Customisation Trick: A pattern for avoiding unghosting
Waaaay back on day 2 of 1-BPD-until-Christmas (remember, we're at 19 now!), I posted a vNext wishlist item around smarter customising in SharePoint Designer, and didn't present a workaround. Thinking about this recently, I realised that you can avoid the frighteners by hacking around with a temporary page.  Here's the general idea/pattern:
  1. Create a temporary, throwaway page in SharePoint Designer (hence call it aSsdsdsdsSD.aspx).
  2. Create your Data View, and get everything looking pretty.
  3. Save, and open in the browser.
  4. Use the web part context-menu to export the data view to a .dwp file.
  5. Open the page you want to place the Data View on (but don't want to unghost/customise) in the browser.
  6. Add a web part, then use the drop-down in the gallery to import the .dwp.
  7. Delete aSsdsdsdsSD.aspx.

A tad annoying, but a useful way of avoiding customised pages nonetheless.

:) Matt

Customisation Trick: Forcing the web part properties pane to open via the URL
Day 16 of OBPDUC.  Less talk, more blog.
 
Have you ever needed to open the web part properties pane, or enter edit mode for a page but couldn't?  There are a number of ways this can occur, such as when you've hidden the Site Actions from a page, or when you're in an out-of-the-box new/edit form and there's no Site Actions -> "Edit Page" command.
 
The following text when added to the query string of your URL will forcibly open the web part properties and throw you into edit mode.
?ToolPaneView=2
For example, you can use this to add a web part to an out-of-the-box new/edit item page (without SharePoint Designer) or simply access the web part properties if you couldn't get in there for whatever reason.
 
:) Matt
SharePoint Customisation Tricks: Getting Funky with the Content Editor Web Part

On the first day of one-blog-per-day before Christmas, my true love1 gave to me: The Content Editor Web Part (CEWP)!

Many of us use the CEWP to add additional rich HTML content to our pages. That's pretty logical, since this is primarily what the CEWP is designed for! However, here are some other funky ways you can use the CEWP (with source code view) when customising SharePoint:

  • Styles: Use the CEWP to output a <style> tag to override one or more styles on the page. As the inline styles are applied last, this is a pretty guaranteed way of messing with the look and feel.
  • JavaScript Injection: Use the CEWP to output some Javascript that does... well pretty much anything you can dream of. Throw out some alerts, manipulate some form controls on the page, do something AJAXy, or if you're really cool, use this great idea from Gary to leverage JQuery inside SharePoint.

    This general approach has been around for a while and there's heaps of examples out there on the web - e.g. try the infamous snow theme from http://www.contenteditorwebpart.com/.

  • Hiding Stuff: Really an extension of both of the above... but you can do things like hide the quick launch, or any element on the page by outputting a bit of JavaScript that manipulates the "display" style element of an object.
  • Timed Calls: Again, really an extension of "JavaScript Injection" - but by outputting some JavaScript setTimeouts you can do stuff to objects on the page on a schedule. Redirect the user, make an AJAX call, remind them to MicroPause (by clicking "OK") every 2 minutes...
  • Embedding and Mashing: Use the CEWP to embed other application's objects in your pages, such as the Windows Live Messenger box you see on the right of this blog, or a Flickr panel, or a ClustrMaps box, or just about anything. In fact, by outputting things like Google Gadgets you've effectively got a whole 'nother Web Part Gallery out there... the Web!
  • Rich Content: Not just bold and italics - use the CEWP to output rich media content including Flash and Silverlight.
  • Client Side IFraming: Outputting an IFrame within a CEWP can be useful to "integrate" other web applications - a lot of people do this sort of thing to show views of CRM, or SalesForce, or <insert complimentary application here>. The Page Viewer Web Part sort-of does this but it's on the server, which can create authentication issues and delays.

Note that with many of the examples above, you might want to repeat these changes across multiple pages in your site. Though you could export/import the webpart content, If you find yourself repeating this in a large number of files, it's probably time to consider customising the master page or page layout instead.

Finally, a word of warning about using the CEWP: just like other web parts, the CEWP is not versioned.  The content you place inside the CEWP will overwrite any existing content, which cannot be rolled back nor maintained consistently with other fields on the page. I frequently see too much use of CEWPs in publishing pages - consider getting yourself a better page layout if you're always adding a CEWP in the same place.

Day 1 - done!

:) Matt


1. SharePoint
TechEd 2008 - OFC303 - Deck and Resources

Hey Everyone,

Sorry for the delay in posting my TechEd deck and links up - I've been sick the last few days.

Matt (Left) and Zac (Right) presenting @ TechEd!

First - the downloads:

Next - here's some links and other info relevant to the content we showed in each of the 8 "rehab" steps (also click here to read Zac's content post).

Hope you've all managed to cure your SharePoint addictions since getting back home!

1. Optimize your development environment

Aside from the hardware optimization and tuning tips, Zac also demoed a few shortcuts. Here's some of the more useful ones:

2. Get a productive build cycle

In this I demoed both Visual Studio Extensions for WSS and STSDEV, and also mentioned WSPBuilder and Andrew Connell's Project Utility Window. Custom build scripts were also shown in the deck but not demoed - the code ZIP includes the OFC303.HelloWebPartCustomScripts project that was used to generate the screenshots in the deck.

Note that if using STSDEV with IIS7, you'll need to customise the Microsoft.SharePoint.Targets file for configurations that reset the app pool - see the STSDEV project in the code ZIP for a version of this. Also, the default configurations output by STSDEV do not support debugging, so to enable this (for each configuration you want to debug in) you need to:

  1. Access project properties (right-click project name, "Properties") and click the "Build" tab
  2. Click "Define DEBUG constant" and "Define TRACE constant"
  3. Click "Advanced"
  4. Change "Debug Info" to "full"

The last part of the demo in this section concerned the F5 DebugApp. In time I'll post a more detailed article describing the whys and hows of this approach, but in short here's how you do it:

  1. Create a web application project in Visual Studio (File -> New -> Project -> ASP.Net Web Application, not File -> New -> Web Site).
  2. Move the .csproj and .csproj.user files, along with the Properties folder, into C:\inetpub\wwwroot\wss\virtualdirectories\<x>, where <x> is the name or number of the web application corresponding to the SharePoint site you'd like to debug on.
  3. Attach the project to an existing solution (e.g. STSDEV project).
  4. Set as startup project (right-click project name, "Set as Startup Project").
  5. Access project properties (right-click project name, "Properties") and click the "Web" tab.
  6. Under the "Servers" setting, click "Use IIS web server", then enter the URL to the SharePoint web application you want to debug on, e.g. http://mymachine:99.

Kapow! F5 debugging against SharePoint.

3. Don't be a tool, be a better developer through tools!

Links to the tools we showed (in order):

More tool links can be found in the deck itself, particularly the "What's in our toolkit (partial)" slide, which Zac has also replicated in his post.

4. Only code when you have to

Links from Zac's post: Community Kit for SharePoint, Search Community Toolkit, Pod Casting Toolkit, Fantastic 40 Templates, Telerik Controls, Bamboo Solutions

5. Use the right tool for the job

In the first slide of this section, I mentioned a method for extracting list definitions from lists already set in the browser. Here's some tools/links that can help with this:

  • Andrew Connell's STSADM extensions - useful for extracting site column and content type XML.
  • Imtech STSADM extensions - effectively does the same thing as the SharePoint Solution Generator (part of the SDK), but without the GUI.
  • Also see Step 5 in Ari's post on creating custom list definitions. Once you've extracted the schema (using Imtech or the Solution Generator), you'll want to follow this step to hook up the Content Type used by the list to the site-level Content Type rather than the copy of the Content Type that the list gets.

In time, I will also post a script for extracting a list def with content types and site columns correctly hooked up in one go - it's not quite "community ready".

In terms of the User Control demo shown in this section, the code ZIP includes both the OFC303.UserControlWebPart and DebugApp projects, though without the SQL albums database (that was used to generate the ListView) this code won't deploy. However, the AjaxWebPart.cs that I inherited from (to get Ajax working) may be useful to some, as might the relatively simple UserControlWebPart.cs. Also in the code ZIP is an AjaxEnabler project I wrote to automate all the custom Web.config tweaks that get AJAX working. This is similar to "Ajax.Config" as available on the CodePlex Features project, but that wasn't around at the time.

6. Get friendly with Powershell

Zac showed a couple of quick demos of Powershell use in SharePoint. Here's a guide to get you started (from Zac's post). I'll try to post my own views on this in upcoming weeks.

7. Make peace with SharePoint Designer... it's for developers, too!

In terms of the features that were demoed, I showed:

  1. Creating a Linked Data Source combining SQL and SharePoint data
  2. Multiple item grid views and alternative layouts
  3. A joined sub-view that linked the SQL data with SharePoint data based on a "foreign key"
  4. No-code conditional formatting
  5. No-code two-way data binding with a single item form
  6. Web part connections between the grid view and form
  7. A completely custom XSLT rendering that generated a Silverlight chart from a data source

The code ZIP excludes the "code" for this demo (other than the Visifire XSLT), as without the database and specific SharePoint data this is relatively useless. However, here's a few links that may be helpful:

8. Get help faster, and stay up to date

Here are the links from the deck:

I also have a list of Essential SharePoint Resources up on my blog.

If nothing else, I recommend you subscribe to the aggregate blogs above. The best information usually has a way of getting through on these blogs.

Ask the Experts!?

Thanks again to everyone who attended, and for all the positive and constructive feedback. Until next time!

:) Matt

C-SPUG: 7 tips for Productive SharePoint Development

Tonight I co-presented at the Christchurch SharePoint User Group "lightning talks" sessions.  The idea here (which I stole loosely from Kirk Jackson and the Wellington .NET Group) was to have a number of speakers present short, sharp topics intended to give a broad overview for attendees in several different subject areas.  I think this was an interesting and fun concept, though it's hard to keep a presentation to 15 minutes when SharePoint is involved!

The slides from my 15 minute session on productive SharePoint development can be found here.  As a good introduction back into the world of blogging, I'm going to prepare a 7-part blog over the next couple of weeks that replicates and expands on the content from the 7 tips in the presentation.

Also check out Gary and Peter's blogs - I am sure they will post their resources in time.

If you were at tonight's session and have any additional tips of your own, or perhaps disagree with some of mine, I'd love to hear from you!

As an aside, I apologise profusely for my incredibly poor jokes in this and other presentations.  Despite this I am absolutely 100% confident that I'll continue to make bad jokes in the future.

:) Matt