Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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);
        }
    }
share|improve this answer
    
Hi Tomasz, Thanks for the update it work for me. –  ahamedzakeer Jul 20 '11 at 13:18
add comment

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.

share|improve this answer
    
HI Anita Boerboom, Thanks for the update it work for me. –  ahamedzakeer Jul 20 '11 at 13:17
add comment

Your Answer

 
discard

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.