Customizing SharePoint list form adds Page tab to ribbon

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:

Custom List Form with Page Tab in RibbonOn the other hand, if you follow the approach in the article for editing an existing list form, you won’t see the extra tab.

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:

  1. Click on the Lists and Libraries node in the Navigation pane.
  2. Click on the list for which you’re creating the custom form.
  3. In the Forms section, click the ‘New…’ button in the header.
  4. Fill out the fields and click OK.
  5. Right-click on the new form, and choose ‘Edit File in Advanced Mode.’
  6. Change the view to either ‘Split’ or ‘Design’ view (Code view doesn’t enable some of the buttons on the ribbon).
  7. Click above or below the DataFormWebPart that’s already on the page. I usually click the space just above it.
  8. 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.
  9. 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).
  10. Click the newly inserted ListFormWebPart to select it.
  11. Open the Web Part Tools contextual tab in the ribbon.
  12. Click the Properties button in the Web Part group on the left.
  13. 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.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s