How to close dialog box which is opened by jQuery?
<p>I have a webpage in which I open a dialog box, which shows another webpage. When I click on the submit button on this child webpage, it is loaded in the browser window.</p>

<p>Here is the whole synopsis:</p>

<p>On the parent page, I have a div which loads the child.</p>

<pre><code>&lt;div id="divMyDialog" title="Child Dialog Title"&gt;
&lt;/div&gt;
</code></pre>

<p>In a jQuery file, I have the following:</p>

<pre><code>$("#divMyDialog").dialog({
    autoOpen: false,
    bgiframe: true,
    width: 800,
    height: 400,
    modal: true,
    draggable: false,
    resizable: false
    });

function OpenDialog(FirstID, SecondID) {
    $("#divMyDialog").dialog("open").load("ChildPage.aspx?FirstID=" + FirstID+ "&amp;SecondID=" + SecondID);
}
</code></pre>

<p>Now, once I click on an asp:button in ChildPage.aspx (after a database action), I want ChildPage.aspx to show an alert and then close. Instead, what is happening is that it shows the alert correctly, and then loads ChildPage.aspx in the browser.</p>

<p>For the alert, I have this in the OnClick event for that asp:button:</p>

<pre><code>Page.ClientScript.RegisterStartupScript(this.GetType(), "showalert", "&lt;script&gt;CloseMyDialog();&lt;/script&gt;");
</code></pre>

<p>To close ChildPage.aspx dialog, I have this:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function CloseMyDialog() {
        parent.$.fn.colorbox.close();
        return false;
    }
&lt;/script&gt;
</code></pre>

<p>Please let me know if you need any more clarification. I have already tried many things, but so far none worked correctly.</p>

<p>Thanks.</p>
