OK, so I’ll admit I skipped a month and didn’t add any new posts in July. Aside from a vacation I took in the mountains that month, the other reason I’ve been away for a while is I’ve been playing with Office 365 and SharePoint Online, and the possibilities are pretty exciting! If Office 365 is a topic of interest to you, stay tuned… I’ll be writing some posts on it soon.
Now back to the topic at hand. As I suspect you already know, SharePoint 2010 lets you customize the list forms used for viewing, editing, and creating list items. You can customize them in the browser, using SharePoint Designer 2010, or even using InfoPath (if you have the Enterprise edition of SharePoint Server 2010).
For this post I’ll focus on SharePoint Designer since that’s where I saw this behavior. In this article from Microsoft, two approaches are presented for creating a custom list form in SharePoint Designer 2010: Creating a new list form and editing an existing one (for example, editing the existing DispForm.aspx file).
If you go with their approach of creating a new list form, the page that’s created uses a DataFormWebPart to render the form on the page. That’s all well and good, but when you open the form in a browser, you’ll see a Page tab suddenly displayed on the ribbon as shown below:
Why is that? Because the first approach doesn’t have a ListFormWebPart on the page, which is what the default list forms use to render their content. The second approach, however, hides the existing ListFormWebPart and leaves it on the page when the new DataFormWebPart is added. The ListFormWebPart contains logic that hides the Page tab in the ribbon, which is probably what you want on a custom list form (since the usual ‘Edit’ link and other page-related functions are on that tab, even if disabled).
So here’s the moral of the story: If you create a new custom list form and want the Page tab in the ribbon to be hidden, make sure your form has a ListFormWebPart hidden somewhere on the page (it doesn’t have to be the first web part – it can be anywhere).
Here are some steps you can follow in SharePoint Designer 2010 to do that:
- Click on the Lists and Libraries node in the Navigation pane.
- Click on the list for which you’re creating the custom form.
- In the Forms section, click the ‘New…’ button in the header.
- Fill out the fields and click OK.
- Right-click on the new form, and choose ‘Edit File in Advanced Mode.’
- Change the view to either ‘Split’ or ‘Design’ view (Code view doesn’t enable some of the buttons on the ribbon).
- Click above or below the DataFormWebPart that’s already on the page. I usually click the space just above it.
- On the Insert tab of the ribbon, look at the Controls group. Click the arrow beneath the SharePoint button, and choose “List Form…” at the bottom of the menu.
- Choose the list you’re customizing, pick the appropriate type of form, and click OK (the ‘Show standard toolbar’ check box can be checked or not – it doesn’t matter).
- Click the newly inserted ListFormWebPart to select it.
- Open the Web Part Tools contextual tab in the ribbon.
- Click the Properties button in the Web Part group on the left.
- Under the Layout section, choose Hidden and click OK.
That’s it. Now do whatever else you want to customize your form, and when it’s opened in the browser, the Page tab will not be visible in the ribbon.