If you have built a few Iron Speed applications, then you will have
come across Add Record links placed next to your drop downs on your Add
and Edit pages. These buttons open a popup containing the Add Record
page, which allows you to add a new item which is then added to the drop
down on the main page. A slight problem with these popup windows is
that they have the full header, footer and menu of a normal page. This
generally doesn’t look very nice and can lead to odd situations where
the user is browsing the application in the popup rather than the main
page.
There are two solutions to this, the obvious one being to create a
second version of the Add page in the designer and use this for the pop
ups. The second more efficient option is to dynamically change
the master page based on where you are coming from. This way you only
have one Add page which works like a normal page until its opened by an
Add Record link, in which case you switch the page to use the blank
master page.
Implementing this in code is very simple. Iron Speed has already done
most of the leg work for you. When the Add Record link button is
pressed the popup window has a URL parameter called target. You can
check for this when the page loads and change the master page if it has a
value.
C#
string TargetKey = this.Page.Request.QueryString["Target"];
if (TargetKey != null) {this.MasterPageFile = "../Master Pages/Blank.master";}
VB.Net
Dim TargetKey As String = Me.Page.Request.QueryString.Item("Target")
If Not TargetKey Is Nothing Then
Me.MasterPageFile = "../Master Pages/Blank.master"
End If