paeep
asked on
How to close a modalDialog from a webpart page in Sharepoint 2010
Hello all,
In sharepoint (2010 foundation) I am trying to use the SP.UI.ModalDialog.showModa lDialog function to open a webpart page.
(and it succeeds!!)
However: closing the modalDialog fails. It seems I am closing the webpart page displayed inside de modalDialog but the dialog itself stays open.
The webpart used is a SmartPart, which reads the contents of an aspx file from the server.
This is the code I use to open the dialog:
...And below is the code I (try to) use in the webpart page :
As said earlier: the webpart page itself is closed, but the dialogbox stays open and has to be closed manually.
Can someone help me with this?
Thanks,
Paul
In sharepoint (2010 foundation) I am trying to use the SP.UI.ModalDialog.showModa
(and it succeeds!!)
However: closing the modalDialog fails. It seems I am closing the webpart page displayed inside de modalDialog but the dialog itself stays open.
The webpart used is a SmartPart, which reads the contents of an aspx file from the server.
This is the code I use to open the dialog:
<script language='text/javascript'>
function UurRegistratieWBS(LineNr, lblAfk, projectNr, BudgetCode) {
var options = SP.UI.$create_DialogOptions();
options.url = '/ERP/SitePages/UurRegistratie.aspx?wbsnr=' + LineNr + '&user=' + lblAfk + '&project=' + projectNr + '&BudgetCode=' + BudgetCode;
options.title = "Tijdsregistratie WBS";
options.showClose = true;
options.autoSize = true;
options.dialogReturnValueCallback = Function.createDelegate(null, CloseDialog);
SP.UI.ModalDialog.showModalDialog(options);
}
</script>
...And below is the code I (try to) use in the webpart page :
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSluiten.Click
Me.Response.Write("<script language='text/javascript'>SP.UI.ModalDialog.close(SP.UI.DialogResult.cancel);</script>")
Me.Parent.Page.Response.Clear()
Me.Parent.Page.Response.Write("<script language='text/javascript'>SP.UI.ModalDialog.close(SP.UI.DialogResult.cancel);</script>")
End Sub
As said earlier: the webpart page itself is closed, but the dialogbox stays open and has to be closed manually.
Can someone help me with this?
Thanks,
Paul
ASKER
Hey,
I already tried that kind of code (it's all over the internet ;-) )
Could there be a possibility that my modalDialog is opened twice?
--> after I 'close' the dialog, it seems to grow a little in size (as in a default modal popup dialog)
However, I only get 1 result from the callback function.
I already tried that kind of code (it's all over the internet ;-) )
Could there be a possibility that my modalDialog is opened twice?
--> after I 'close' the dialog, it seems to grow a little in size (as in a default modal popup dialog)
However, I only get 1 result from the callback function.
Instead of SP.UI.ModalDialog.close() method try window.close()
ASKER
That was the initial setup.
Doesn't work either...
Doesn't work either...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
final solution
ASKER
I found what I needed explicitly through one of your links:
http://blogs.msdn.com/b/sharepointdev/archive/2011/01/13/using-the-dialog-platform.aspx
Thanks!!
http://blogs.msdn.com/b/sharepointdev/archive/2011/01/13/using-the-dialog-platform.aspx
Methods Inside a Dialog
When you’re inside a dialog, there are alternate methods to operate on the dialog. The APIs are created dynamically to increase performance and keep from loading the entire SP.UI.Dialog.js file since it is loaded in the parent window. The following methods and properties are available using the window.frameElement class.
...
Thanks!!
pl refer: http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/f0e487d1-bf4a-4e86-87f5-b3a61db2ecb7#f0e487d1-bf4a-4e86-87f5-b3a61db2ecb7
as I was unable to try the above solution I am posting the link
hope this helps