views:

26

answers:

2

I'm aware there are other questions similar but I just cannot get this to work.

Id like to close the colorbox iframe on the click of a .NET Button form within the iframe.

<script type="text/javascript">
$(document).ready(function() {
    $(".del-add").colorbox({ width: "800px", height: "660px", iframe: true, open: true });
});
</script>

Button

    <asp:ImageButton ImageUrl="~/images/update_b.jpg" ID="but2" runat="server" OnClick="UpdateAddress" Visible="true" ValidationGroup="valEnquiry" />

If someone could be kind enough to spell it out to me in plain english that would be much appreciated.

thanks very much

A: 

Try this

$("#<%=but2.ClientID%>").click(function(){
    $.fn.colorbox.close();
});
rahul
Does this code go in the iframe or in the MasterPage?
Mark
A: 

This is what worked for me:

parent.$.colorbox.close();

You should make this your last line in "UpdateAddress" and return false so the page doesn't postback. If you need to postback then just after returning from postback invoke that line.

Mike