I am using colorbox to open a page in iframe. In that page i use ajax file upload to upload image asynchronously and then bind a datalist of new images.I have a button on the same page to close the iframe using this code
protected void Cancel_Click(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "none", "<script>$(function(){closeIframe()});</script>");
}
It works fine when i do not upload any image and click it. it closes color box but when i upload image and click it, then it takes me to a different page and gives following js error.
Uncaught TypeError: Cannot call method 'close' of undefined
This is the function which i use to close popup
<script>
function closeIframe() {
parent.$.fn.colorbox.close();
}
</script>