I have problems with multiple modal dialogs using IE 9 browser. When I click on the Ok or Cancel button on the second modal form, I get following exception from my js code.


when I try once again to press Ok or Cancel button I get


It works fine on Chrome and Firefox.

on my first dialog I have a link button and this fires a standard js function

function AddContributor(id) {

    var currentUrl = window.location.href;
    currentUrl = currentUrl.substring(0, currentUrl.lastIndexOf('/') + 1);

    var options = SP.UI.$create_DialogOptions();
    options.url = currentUrl + "/SecondPage.aspx?id=" + id;
    options.title = "Add";
    options.width = 700;
    options.height = 600;
    options.dialogReturnValueCallback = AddContributorCallback;


function AddContributorCallback(dialogResult, returnValue) {
    if (dialogResult == SP.UI.DialogResult.OK) {
    if (dialogResult == SP.UI.DialogResult.cancel) {

1 Answer 1


first looking at your code you have taken the if statment out of the try catch block where it should be inside the try block so you can catch the error when debugging.

The next issue is that it returning null, probably because its out of the try catch block and/or the object doesnt exist in that time when your clicking on it so your calling somthing (object) that hasnt been created yet or has been desposed off causing it to be null.

as i cant properly see a part of the code that could be causing it I can only speculate that you have click on the first modal which runs fine but then on the second one it throws the error as it doesnt exist what your calling or the code that its failing on is not in the right place!

hope this helps :)

  • Thanks for your reply. The code you have seen is not my code. It's standard sharepoint modal-dialog js.
    – aph5
    Sep 24, 2012 at 13:23
  • ok no problem, so how did you add the dialog?
    – Ali Jafer
    Sep 24, 2012 at 13:27
  • I have updated my question above.
    – aph5
    Sep 24, 2012 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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