“Pub is Undefined” Error on Custom Page

When I create a custom page for SharePoint or indeed any custom branding, I like the minimalist approach.  That is a strip out all the OOTB stuff and go back to the minimum I can get away with.  Only this time when I stripped this particular page/masterpage back I ended up with the javascript error “Pub is Undefined”.  Well in fact I didn’t see that error until I used the F12 tools in IE.  The symptoms were that the page just would not switch to Edit mode unless I called the action from the main “Site Actions” menu. Using the “Edit” button on the menu didn’t work.  Had to be a javascript error for sure I thought.  So I just got out the V4 masterpage and began stripping back again until I came to this well known Delegate Control:

<SharePoint:DelegateControl runat="server" ControlId="PublishingConsole" Id="PublishingConsoleDelegate" />

Which seemed to be the culprit.  No actual Publishing console appears in SharePoint 2010. It’s all in the Ribbon.  But I guess some little leftover from 2007 seems to require this to work fully.  I guess it just forces the loading of the SP.UI.Pub.Ribbon.js which seemed to be the missing file.  So there you go, another solution to the mysterious “Pub is undefined” error when building hghly customized SharePoint pages which use the Publishing Features… you still need the above control for everything to work smoothly.

Cheers

Dave Mc

 

 

Advertisements

About davemcmahon81
Software Developer & Architect, User Group Leader, Speaker, Writer, Blogger, Occasional Guitarist, Man-made Global Warming Sceptic, Climate Change Believer, General Optimist but most of all proud Husband and Dad ...

7 Responses to “Pub is Undefined” Error on Custom Page

  1. Celbester says:

    Dave, thank you so much! You just saved me a lot of time!

  2. MartinB says:

    Thanks a bunch.
    Works like a charm (if the delegatecontrol is missing that is).

  3. Thanks Dave. This is really helpful. U saved my UAT build 🙂

  4. tyampu says:

    Dave, thank you for the post.

    I ran into the same issue and was able to resolve it with one masterpage but second masterpage still gives same error, although I have added this control. Is there any other controls/contentplaceholder (if missing) could cause this issue?

    Thank you.

    • Is the second masterpage in a different site? Can only suggest at the moment that you check for any other javascript errors and check that the javascript file links all match.

      Cheers

      Dave

      • tyampu says:

        I guess sometimes you need a second eye or in my case … little bit of sense. It’s spelling mistake that I had on my second master page delegate control that was causing the issue. I know its inexcusable but I am just glad it’s working. Again thanks Dave, your solution rocks!

  5. Thank you Dave,

    2 days I’m looking for a solution. thank you very much

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: