DotNetNuke 6, PopUps and Module Controls

After I upgraded to DNN6 I discovered the PopUpURL class.  Like most DNN classes there’s very little in the way of documentation and I had to stumble around with it for awhile to get it to work.  In the end, there’s not much to it.

Attach an onclick event to a server side control and use the PopUpURL as the script to call.

Call the PopUp

{Button Control}.Attributes.Add(“onclick”, “return ” + UrlUtils.PopUpUrl(EditUrl(“{Control Key”) & “?mid=” & Me.ModuleId.ToString() & “&{query string parameter=” & {parameter value}, Me, PortalSettings, True, False, 500, 600))

That’s what the standard string looks like.

{Button Control} – the ID of your button control

{Control Key} – the Key of the Module Control

I include the current module id in the query string because I am typically calling pop ups from the edit control.

{query string parameter} – This is optional, but I included it so you can see how to send parameters to the pop up.

True – this refers to the “onclick” event.  Setting to true instantiates the event

False – for Response.Redirect.  I set it to false.  I haven’t found a reason yet to set it to true

500,600 – these are just window height and width settings

There are two other parameters which come in handy

Refresh – if this is set to false the calling page will not refresh.  When not using this parameter the PopUp will always refresh the calling page.

Closing URL – on closing the pop up it will return to this url instead of refreshing the calling page.

Closing the PopUp

Normally when you close a module control you just use NavigateURL() to get back to the view control.  For me, since I’m usually calling a pop up from the Edit control, I have to close the PopUp using code like this in cmdCancel OnClick event

Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(Me.TabId, “Edit”, “mid=” + Me.ModuleId.ToString() + “&{query string parameter}=” + {parameter value}.ToString()), True)

Leave a Reply

Your email address will not be published. Required fields are marked *