SharePoint: Refreshing the page after you close a modal dialog

SharePoint 2010 introduced the modal popup dialog – many settings & features open a nice-looking dialog window rather than changing your current location or opening a whole new window like they did in previous versions. It’s all smoke and mirrors, of course – in reality you’re still opening a different window, it’s just a nice little formatted one that acts like a dialog box instead of a browser window. SP2010 comes with a packaged function for opening these windows called OpenPopUpPage, and it’s used like the following example:

modal-refresh1

This example opens an InfoPath list form. The “?IsDlg=1” part tells it not to show the navigation & other site elements. Overall, this is a handy way to deliver forms & settings pages without interrupting the user experience. Sometimes, though, you need to refresh the original page after the user finishes with the modal dialog – when changing content on the page, for example. In my case, I just tacked a window.reload(); onto the end and thought I was done. What I found, though, was that the refresh was occurring in tandem with the popup… which effectively killed the popup.

A quick google session found a few solutions, the first few of which involved writing my own function to replace the OOTB SharePoint one or overly-complicated JQuery. The fifth result I looked at, however, had a very simple solution that does exactly what I want. Turns out that all  you have to do is add the RefreshPage attribute to the event like so:

modal-refresh2

This one little change tells the function to refresh the page after closing the popup. Nice.

Advertisements

3 responses to “SharePoint: Refreshing the page after you close a modal dialog

  1. Hey, I saw your post on “http://davecavins.com/2009/12/displaying-document-titles-as-links/” about how you “Used a workflow to set the two values of the “Document Link” field, using the Title column as the description and the item URL as the address” to get a link on a different column other than Name. I’m running into a little problem here on the workflow, how exactly do you set it up?

    I have little experience with them, and just got started using the actions. I had hoped to keep the name of the original file, but create a link out of the title, and my original workflow was to set the name as the title, but it just ended up renaming the name of the pdf (which I want to avoid). Any help would be great! Thanks!

    Like

    • Sure – first you need to do two things on the library itself

      1. Make the Title column required so it can’t be left blank
      2. Add a new URL column called “Link” or something

      Then in the workflow, you want to update the Link field in the current item. The Link column will have two values to fill in – the description and the address. Use the Title column for the address and the Encoded Absolute URL for the address.

      Alternatively, if you didn’t want to make Title required, you could make the first step of the workflow take the file name, strip off encoded characters & the extension, then put that into the Title field. Not as pretty, but it would still work.

      Like

  2. Thanks for the quick response.

    I have already set up the library with those column requirements – but I’m not exactly sure where to start with the workflow. Sorry if I’m being too vague here, just not too experienced with workflows in sharepoint yet. In able to update the Link field to have the two values fill in (description and address), would that be a “update list item” action? How would I word that within the workflow to set the description and address of the link column?

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s