Wednesday 4 May 2016

How to close a Modal Dialog from a Provider-Hosted App using code-behind

Hi Guys,

If you are facing a challenge while closing a modal dialog in a provider hosted app, using code behind then please use the script below.

How to close the Modal Dialog of a Provider-Hosted App using code Behind...

1. If you want to refresh your parent window after closing your dialog then use the script below:

  HttpContext.Current.Response.Write("<script language='JavaScript'>window.parent.postMessage('CloseCustomActionDialogRefresh', '*');</script>");

2. If you don't want to refresh your parent page after closing your dialog then use the script below:

HttpContext.Current.Response.Write("<script language='JavaScript'>window.parent.postMessage('CloseCustomActionDialogNoRefresh', '*');</script>");

I hope this will help you a lot...

Happy coding.... :)

Regards!!

Pankaj Srivastava