SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering is there is a way to use the existing modal popup already used by SharePoint and override its callback?


share|improve this question
up vote 3 down vote accepted

Yea, there is a dialogReturnValueCallback option when using the SP.UI.ModalDialog.showModalDialog. See

In the callback function you can test to see whether the user clicked ok or cancel to close the dialog.

var options = SP.UI.$create_DialogOptions();
options.url = url;
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);

// Dialog callback
function CloseCallback(result, target) {
    if (result === SP.UI.DialogResult.OK) {

    if (result === SP.UI.DialogResult.cancel) {

share|improve this answer
What i want to do first is open an already existing modal creating when you install sharepoint, how can i do that ? – Dr.Denis McCracleJizz Apr 12 '12 at 16:11
So you want to tap into when SharePoint opens a modal and know when it's closed? What are you trying to accomplish with this? – Steve Lineberry Apr 12 '12 at 16:47
Yes i want to use something like, ModalDialog.Open("/UserRegister.aspx") to open already existing Sharepoint Modal – Dr.Denis McCracleJizz Apr 12 '12 at 16:58
What do you mean by an already existing modal? I don't see where my code above doesn't help you with the example you gave. Sorry. – Steve Lineberry Apr 12 '12 at 17:13
Sharepoint already has Modal popup defined, for when you add permissions for exemple, sharepoint will open a modal popup, i want to use the same modal popup but change its onclick and close callback. – Dr.Denis McCracleJizz Apr 12 '12 at 18:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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