How to hide a master page div when displayed in a SharePoint dialog box?

In this SharePoint customization tutorial, we will discuss how to hide master page elements in the dialog box in SharePoint 2013.

Recently we were working in a migration web site from MOSS 2007 to SharePoint 2010 and then to SharePoint 2013 by using the database upgrade approach. There we were using a master page and on that master page, there was a navigation menu presented there. That navigation menu was coming in our Add item in list dialog boxes.

When I search I found a very good post from Eric and followed that and it works like a champ. Thanks, Eric for sharing this.

In SharePoint 2013 there is a class known as “ms-dialogHidden”. If you will add this class to the HTML block, that Html block will not appear in the dialog boxes.

Example:

<div id="global-menu" class="ms-dialogHidden">
Here was our global menu.
</div>

After this, the above section will not appear in the dialog boxes in SharePoint 2013. We can check this in Master pages, Page layouts or any other pages referenced from the master pages.

The same thing works in SharePoint 2010, but with a different class name. The class name is: “s4-notdlg”

Example:

<div id="global-menu" class="s4-notdlg">
Here was our global menu.
</div>

Here is an example wherein Add new item dialog box one of our global navigation is coming like below:

hide a masterpage div when displayed in a SharePoint dialog window
hide a masterpage div when displayed in a SharePoint dialog window

And after using the ms-dialogHidden class, the global navigation did not appear like below:

hide a masterpage div when displayed in a SharePoint 2013 dialog window
hide a masterpage div when displayed in a SharePoint 2013 dialog window

You may like following SharePoint master page tutorials:

Hope, this SharePoint tutorial helps to hide a master page div when displayed in a SharePoint dialog window.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>