function () {
var o = { url:'{SiteUrl}/_layouts/Modalwindow.aspx, title: 'Select Destination Site', allowMaximize: false, showClose: true, width: 500, height: 500 };
SP.UI.ModalDialog.showModalDialog(o);
} ();"
I had to bang my head on the desk to get the solution. searched the net for about 2 hours and still nothing. Many people has asked me to use dialogreturnvaluecallback and others asked me to use commonModalDialogClose and many other ways. None of them worked for me. Please don't bother to go through MSDN documentation about SP.UI.ModalDialog. THAT DOES NOT WORK!!!!.
so finally I got the code that WORKS...:)
Response.Write("< script 'text/javascript'>window.frameElement.cancelPopUp();< /script>");
Response.Flush();
Response.End();
This code should be added in the cancel or close button clicked event in the backend. For committing the form use window.frameElement.commitPopup();
:) Thank you