Check, if you are within a modal dialog
By now, you probably know that the modal framework from SharePoint 2010 is a great thing 🙂
In case you need to find out if the context is within a modal dialog, you can query for the URL parameter “IsDlg”.
if (Page.Request["IsDlg"] != null) { // within a modal dialog } else { // not within a modal dialog }