在回发关闭颜色框 [英] Close colorbox on postback

查看:97
本文介绍了在回发关闭颜色框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的颜色框在iframe中打开一个页面。在这个页面我使用ajax的文件上传到异步上传图像,然后结合新images.I一个DataList具有相同的页面上的按钮使用此code,关闭了iframe

 保护无效Cancel_Click(对象发件人,EventArgs的发送)
    {
       ClientScript.RegisterClientScriptBlock(this.GetType(),无,<脚本> $(函数(){closeIframe()});< / SCRIPT>中);
    }

当我不上传任何图片,点击它,它工作正常。它关闭彩色包装盒,但是当我上传图片,点击它,然后带我到不同的页面,并给出以下JS错误。


  

遗漏的类型错误:无法调用的方法未定义关闭


这是我用它来关闭弹出窗口功能

 <脚本>
功能closeIframe(){
    。父$ fn.colorbox.close()。
}
< / SCRIPT>


解决方案

你能不能张贴一个链接到您的项目?
没有这个,我们所能做的是猜测。因此,这里是一个猜测...

您说它带我去一个不同的页面。如果该页面没有加载颜色框,您将收到您所看到的错误。

是,不同的页面的原始页面的iFrame中?如果不是,您将收到您所看到的错误。

要开始挖,这样做:
*重现错误
*页面生成错误上,检查DOM,看是否彩盒被加载。
*如果不是,重新考虑你的页面导航或重新考虑如何使用颜色框。

发布链接到您的项目为更好的帮助。

问候。

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>

解决方案

Can you post a link to your project? Without that, all we can do is guess. So here is a guess...

You say "it take me to a different page". If that page does not have ColorBox loaded, you will receive the error you are seeing.

Is that "different page" an iFrame of the original page? If it is not, you will received the error you are seeing.

To get started digging in, do this: * reproduce the error * on the page generating the error, inspect the DOM to see if ColorBox is loaded. * if it is not, rethink your page navigation or rethink how ColorBox is being used.

Post a link to your project for better help.

Regards.

这篇关于在回发关闭颜色框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆