Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everybody,
I am opening a modal popup in a sharepoint webpart. It has two buttons i.e. Save and Cancel.
When the user clicks on Save button, the modal popup has to be closed and the parent page should be refreshed. But when he clicks on Cancel button, the popup has to be close but the parent page should not be refreshed. Please help me with a way to do this. I have gone through many sites but could not find any answer.

Thanks,
Srivikas.
Posted
Comments
Richard C Bishop 15-May-13 10:44am    
How do you suppose we help you if you do not provide any code?

1 solution

This is the code to open your page in modal dialog. To be used in the parent page

C#
SP.UI.ModalDialog.showModalDialog({
            url: url,
            width: 800,
            dialogReturnValueCallback: function (dialogResult, value) {
                if (value == "1") {
                    window.top.location=window.top.location //this will refreshes the page
                }
            }
        });


This is the code to be used in the "Save" and "Cancel" buttons OnClientClick event

javascript:SP.UI.ModalDialog.commonModalDialogClose(1, '1');

javascript:SP.UI.ModalDialog.commonModalDialogClose(0, '0');

In this example we are sending the callback value to the calling function.
Based on the return value from modal dialog you can specify the action to be performed on the parent page.


Hope it Helps !!

For any calrification reply to this Answer. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900