How To Always Link to the Right Application Pages
As a SharePoint developer you’ve probably run into this problem several times: How to make sure that links to application pages stay valid irrespective of where within a site collection your web part is placed.
If you hand-code links you’re likely to get the path relative to the root site wrong. Even worse, if the the filename of an application page is changed, e.g. from DispForm.aspx to DispFormNew.aspx, your links will surely break.
The application pages
Generally, a SharePoint list contains the following application pages:
- AllItems.aspx
Shows all items in the list - DispForm.aspx
Displays a read-only version of a list item - NewForm.aspx
Form for creating a new list item - EditForm.aspx
Form for editing an existing list item
More applications pages exist but these are the ones most commonly used.
Ensuring unbroken links programmatically
The PAGETYPE Enumeration gives you access to the application pages and enables you to build links that always work.
Assuming you have already created your SPList and SPListItem objects the below snippet builds a link to the correct DispForm:
![]()
Of course, the same applies to NewForm and EditForm.
Linking to the default view of a list
Below a list of elements you may wish to link to the underlying list’s default view. In many cases this will be the AllItems.aspx page but what happens if a user changes the default view in the settings of the list? If you’ve hardcoded a link to AllItems.aspx you may be lucky that the link still works but if AllItems.aspx has been renamed or removed, you’re out of luck.
Instead of hardcoding the link you should use PAGE_DEFAULTVIEW, like this:
Simple, isn’t it?
Groove is now SharePoint Workspace 2010
According to the Groove dev team’s blog, Microsoft Groove is to be integrated more tightly with SharePoint and in the process be given a new name.
SharePoint Workspace 2010 is the new official name for Groove.
I wonder how many more products Microsoft will collect under the SharePoint umbrella before the next release? It seems like Microsoft are aiming to capitalise on the SharePoint name and rebrand some of their lesser known products and even roll them into SharePoint.
Programmatically Checking if a SharePoint Element is Published
Here’s a quick tip for you: How to check if the latest version of an element in a SharePoint list is published.
Once you’ve got hold of an SPListItem, you can check the Versions property (an array containing all the versions of the element).
In this block of code IsPublished becomes True if the latest version is published:
![bool IsPublished = TheItem.Versions[0].Level == SPFileLevel.Published ? true : false;](http://sharepointsharpener.files.wordpress.com/2009/03/image5.png?w=701&h=51)
That’s it.
JavaScript Tips for SharePoint
I’ve gatherered a few productive tips for using JavaScript within SharePoint. The below commands can be used within webparts etc. or directly in the browser’s address field while you’re on a SharePoint page, like this:
Putting javascript: in front of your script snippet will fire it right there and then.
These commands are neither terribly advanced nor applicable on all pages, but they make for a useful reference all the same. I aim to continually update this page with new content so if you have any JavaScript tips, feel free to drop them in the comments.
Edit an application page: MSOLayout_ToggleLayoutMode()
This enables edit mode on SharePoint’s application pages, like EditForm.aspx, DispForm.aspx etc. so you can insert web parts above or below the normal content:
Pop-up an alert with the User ID og the logged-in user: alert(_spUserId)
Enable the Edit toolbar: javascript:__doPostBack(’ctl00$PlaceHolderTopNavBar$SiteActionsMenuMain$ctl00$wsaShowMenu_CmsActionControl’,'reviewPage’)
Simply enables the toolbar where you can access the page edit functions:
Hide the Edit toolbar: __doPostBack(’ctl00$PlaceHolderTopNavBar$SiteActionsMenuMain$ctl00$wsaHideMenu_CmsActionControl’,'exitMenu’)
No prizes for guessing this one.
Show help: TopHelpButtonClick(’NavBarHelpHome’)
Pops up the built-in help page. Interestingly, you can try this on Microsoft’s SharePoint Conference web site:

Travel with the Experts to the SharePoint Conference
Last year PeopleNet gathered more than 30 Danish SharePoint enthusiasts for a series of events at the SharePoint Conference in Seattle.
The events went down a storm and the Danish delegation benefitted a great deal from the networking facilitated by PeopleNet.
Next stop Las Vegas
This year, we are taking things a step further – we are putting together a complete conference package which includes:
- Return airline ticket (Copenhagen – Las Vegas)
- Hotel (Mandalay Bay)
- Conference pass
- Special events during the week of the conference
This way, SharePoint stakeholders from different Danish organisations get to travel with like-minded people instead of going to the conference alone.
For more info (in Danish), click here.
Hardening Your MOSS 2007 WCM Application
This is a re-post of a still relevant post from my old blog at SharePointBlogs.com:
—
Today Last year at the SharePoint Conference in Berlin, Ben Robb of cScape Ltd gave a talk about configuring internet-facing web sites running MOSS 2007/WCM.
He brought up some interesting points about securing the application against unauthorised content editing and attacks from hackers.
Make sure your installation check list contains a least the following items:
1. Enable firewalls and standard network security
Fairly standard stuff, but necessary all the same.
2. Disable SMTP and incoming mail
In essence, you shouldn’t be running services on the server that aren’t necessary for MOSS. Also, close any ports that MOSS doesn’t need.
3. Secure the Central Administration site
Surprisingly, it is very common to leave this entry point wide open. The admin site should be accessible only via an SSL connection .
4. Use lockdown mode
Use this stsadm command to activate lockdown mode:
stsadm –o activatefeature –url <url> -filename ViewFormPagesLockdown\feature.xml
Read more about ViewFormPagesLockdown.
5. Restricted reader role
The anonymous user should have a restricted reader role which only enables viewing of pages, documents and images.
6. Policies
Constrain the maximum access per web application and deny all write access via http://sitename:80.
7. Content deployment
Use different servers for authoring and the actual internet-facing web application. Content generated on the authoring server (typically within the intranet) should be pushed out to the public site using scheduled content deployment jobs.
…
To many administrators the above bullets merely point out the obvious and do feel free to leave comments if you have any additions to the list.
Thanks to Ben Robb for providing 99% of the info for this post.
Confirmed: SharePoint Conference 19-22 Oct 2009 in Las Vegas
As I mentioned three weeks ago, the next SharePoint Conference will be held in Q4 in Las Vegas!
Early bird registration is now open at the conference site.
Focus will be on the next version of SharePoint (codenamed SharePoint 14).
More to follow.
SharePoint 2009 and SharePoint Conference 2009
2009 looks to be a big year for Microsoft, release-wise. The very promising beta of Windows 7 has just been released and Office 14 should be out towards the end of the year.
This gives credit to the rumor that the next version of SharePoint is due to be released in the fourth quarter of this year. There is no official statement from Microsoft which confirms neither when the next release is due, nor what it will be called, but SharePoint 2009 is probably a good bet.
SharePoint Conference 2009 in Las Vegas!
Moreover, the next SharePoint conference is not held in March as usual; it’s been slated for Q4 as well! As you may know, the conference normally swaps between Europe and the US and since last year’s conference was held in Seattle one would assume that this year a return to Europe would be in order.
But one would be wrong in that assumption. A very good source has revealed that the conference will stay on American soil (i.e. Las Vegas). This ties in nicely with the coincidental release of SharePoint 2009. Microsoft obviously want to throw the release party (the conference) of their top products (Office, SharePoint) on their own turf
New Features in SharePoint 2009
Likely new features in SharePoint 2009 are:
- Master Data Management
- 64-bit architecture only
- More use of Silverlight in the UI
- Tighter integration with Groove
In addition, I sincerely hope that Microsoft are rethinking the database architecture behind SharePoint. Most developers are acutely aware that biggest hurdle for SharePoint world domination is the way SharePoint handles relations and large quantities of data.
SharePoint 2007 Service Pack 2
Before version-next we’ll probably see another service pack for SharePoint 2007. Service Pack 2 will bring a number of improvements to the client-side Office applications as well as a few to the server:
- Variations: Performance and manageability improvements including STSADM commands for repairing links between source and target pages
- Office Project Web Access: Improvements around processing status approvals from Office Project Web Access into Office Project Professional 2007
- Content databases: Improvements to read-only content databases and index rebuild timer jobs in Windows SharePoint Services 3.0
Not terribly exciting but more features may materialise before the update hits Microsoft’s download servers.
Developing Workflows Not Possible on 64-Bit SharePoint
As most companies are moving to the 64-bit platform of Windows Server and MOSS, more SharePoint developers are adopting this as their main dev environment.
However, if you plan to develop SharePoint workflows in Visual Studio 2008 on your new 64-bit box, you’re going to be disappointed.
Upon creating a new workflow in VS, an “Object reference not set to an instance of an object”-error pops up:
You can still get to the next step in the process where you have to chose the site which will be used to debug the workflow. Here too, you will be faced with an error:

The solution
Well, there isn’t any. Not right now anyway.
The only thing you can do is to continue developing in your old 32-bit environment and then move your WSP to the 64-bit box for installation.
All this is not a bug per se, rather, it’s down to Microsoft’s lack of resources in their dev team:
(source)
Hmm…
