0

I have an issue in SharePoint 2010, in ItemAdding event i've created some action to be taken when the action is happening and the item is being added, so after that i would like to make sure that the user is redirected to another place.

For that I as usual do like this : SPUtility.Redirect(...)

Btu the issue in this case is that the user is being redirected but the redirection happens in the PopUp Dialog box. But the idea to do it when the dialog box is closed.

I've tried different stuff, but without success, maybe anyone has any idea ... how to do it properly? And perfrom redirect on the main page and not in the pop up dialog box, where the user entered the item details.

Let me know ....

1

If you already know the URL while opening the dialog and you open the dialog yourself, then you could use the dialogReturnValueCallback: http://msdn.microsoft.com/en-us/library/office/ff410058(v=office.14).aspx

If you cannot open the dialog yourself, you might have a chance to render some JavaScript on the page onto which you redirect (within the dialog)? Then you could do something like

<script type="text/javascript">
  window.parent.location.href = 'http://sharepoint.stackexchange.com/';
</script>

This will force the parent window to go to the defined location.

For example you could create a layouts page which grabs a URL parameter and then performs the reload client side..:

Server side (rendered in dialog):

SPUtility.Redirect("_layouts/15/my.solution/redirect_parent.aspx?redirectTo=http://sharepoint.stackexchange.com", ...)

Client-side (executed on redirect_parent.aspx):

window.parent.location.href = GetValueFromRedirectToParam();

I'm not sure if this is nice though, the other approach would definitely be better. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.