title: Close IFRAME Window
body: <p>The below jQuery get trigger by a button on a GridView which allow me to Edit the record in a nice popup Iframe.  However, I need to close the Iframe popup from behind code(c#) of the EditEmployee.aspx page.  I've try almost all the option by searching google and stackoverflow and none seems to be working.  I try add a function on the parent page call CloseDialog() and then call window.parent.CloseDialog() and I can't get it to work.  Can someone please help me, I'm new to jQuery?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('a#popup').on('click', function (e) {
  
              var page = $(this).attr("href")  //get url of link
  
              var $dialog = $('&lt;div&gt;&lt;/div&gt;')
              .html('&lt;iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"&gt;&lt;/iframe&gt;')
              .dialog({
                  autoOpen: false,
                  modal: true,
                  height: 450,
                  width: 'auto',
                  title: "Edit Employee",
                  buttons: {
                      "Close": function () { $dialog.dialog('close'); }
                              },
                  close: function (event, ui) {
  
                     __doPostBack('&lt;%= btnRefresh.ClientID %&gt;', '');  // To refresh gridview when user close dialog
                  }
              });
              $dialog.dialog('open');
              e.preventDefault();
          });
      });
  &lt;/script&gt;
  
   &lt;asp:TemplateField HeaderText="ID"&gt;
         &lt;ItemTemplate &gt;
             &lt;a id="popup" href='EditEmployee.aspx?id=&lt;%# Eval("ID") %&gt;' &gt;edit&lt;/a&gt;
       &lt;/ItemTemplate&gt;
         &lt;/asp:TemplateField&gt;
  </code></pre>