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 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,



Regards, Zakeer Ahamed.S

share|improve this question

try this code

    public static void CloseForm(Page form, string redirectUrl)
        if (SPContext.Current.IsPopUI)
            form.Response.Write("<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(1, '');</script>");
share|improve this answer
Hi Tomasz, Thanks for the update it work for me. – ahamedzakeer Jul 20 '11 at 13:18

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


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


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

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.