Thursday, August 5, 2010

IsDlg Query parameter

Scenario:
With the new design of SharePoint 2010 we have more context aware UI navigation.
We have now popup for pages which shows only the main content of the page.

In case you need to write a new ASPX which you want to display as popup, which master to inherit ??

Solution:
Answer is simple - same default.master , actually SP2010 Design allows you to hide left navigation and top bar just by adding Query parameter

IsDlg=1

i.e. http://intranet.contoso.com/_layouts/create.aspx?IsDlg=1

Assuming you have a custom Div
<div id='customDiv' class='s4-notdlg'> Hello </div>

You can use JQuery to do the adjustments.


<script type="text/javascript">

function querySt(ji) {

hu = window.location.search.substring(1);
gy = hu.split("&");

for (i=0;i<gy.length;i++) {
ft = gy[i].split("=");

if (ft[0] == ji) {
return ft[1];
}
}
}

var IsDlg = query("IsDlg");

$(document).ready( function() {

if(IsDlg)
{
$("#CustomElement).attr('style','display:none');
}

});
</script>


Also one more thing. In case of custom development, if you have some html you want to hide when it is rendered as popup. Apply following css to the div element wrapping your html

class="s4-notdlg"

Try for yourself

Nice to have:
Infact if client have a page with too much content and client want to focus on data by hiding left nav/top bar , you can quickly add a javascript function to give him Toggle functionality for the chrome.

Article
Reading Query String

0 comments: