SharePoint Comic

I needed to create a custom survey in SharePoint a while ago, but had some concerns:

  • Did not want the participants to see the survey overview page.
  • Wanted to open the survey in a modal box from a hyperlink.
  • Did not want the users to return to the overview after they completed the survey.

Used the modal script below that I found on pacsharepoint.com to open up the survey page in the modal box.

Adding the "window.location = "http://www.google.com" under the function 'refreshCallback' allows you to redirect the modal to any page on close.

<script type="text/javascript">
var options = {
url: "/Lists/NewSurvey/NewForm.aspx?IsDlg=1",
title: "My new Survey",
allowMaximize: true,
showClose: true,
width: 625,
height: 525,
dialogReturnValueCallback: silentCallback};
function open() {SP.UI.ModalDialog.showModalDialog(options);}
function silentCallback(dialogResult, returnValue) {
}
function refreshCallback(dialogResult, returnValue) {
SP.UI.Notify.addNotification('Operation Successful!');
SP.UI.ModalDialog.RefreshPage(SP.UI.DialogResult.OK);
}
window.location = "http://www.google.com"
</script>
<a href="javascript:open()">Click Here to Start Survey</a>

The modal appears when you click on the “Click Here to Start Survey” link.

A couple of things to note here – the “options” variable allows you to set the properties of the dialog, one of which is the dialogReturnValueCallback property. Setting this with the silentCallback function (used in the example above) returns to your landing page without a refresh. You can replace this with the refreshCallback function, which will refresh the page and show a pop-up message when an action is configured in the dialog. The best thing to do is play about with it and check out the difference.

Original Link:

http://pacsharepoint.com/2010/07/open-list-item-modal-dialog-lightbox.html