2

I am creating a custom button in ribbon bar for share point 2010. For the button I have mentioned some code in JavaScript. When the custom ribbon button is clicked I have made to open a show model dialog box and inside the model dialog box I have displayed a aspx page which contain buttons. My requirement is if I click the button in aspx page I want to close the show dialog box.

Can anyone guide me for this situation

This is my code snippet for the custom button click .

           url: '/_layouts/FileUpload/Application.aspx',              
            allowMaximize: false,
            showClose: true,
            width: 620,
            height: 208,

            };

SP.UI.ModalDialog.showModalDialog(options);"/>

Regards, Zakeer Ahamed.S

3

try this code

    public static void CloseForm(Page form, string redirectUrl)
    {
        if (SPContext.Current.IsPopUI)
        {
            form.Response.Clear();
            form.Response.Write("<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(1, '');</script>");
            form.Response.End();
        }
        else
        {
            form.Response.Redirect(redirectUrl);
        }
    }
1

To close a dialog box from code behind you can use:

this.Page.Response.Clear();

        if (succes)
        {
            this.Page.Response.Write("<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(1, 'saved');</script>");
        }
        else
        {
            this.Page.Response.Write("<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(0, 'cancelled');</script>");
        }

        this.Page.Response.End();

The parameters of commonModalDialogClose are dialogresult and returnvalue.

  • HI Anita Boerboom, Thanks for the update it work for me. – ahamedzakeer Jul 20 '11 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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