从ASP.Net codebehind触发的fancybox [英] Triggering FancyBox from ASP.Net Codebehind

查看:98
本文介绍了从ASP.Net codebehind触发的fancybox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用的JQuery的fancybox一个asp.net页面上,但所有的例子,我发现节目从触发锚标记一个的fancybox(小于一>)。我没能找到其中的fancybox从codebehind触发一个例子。
更具体地讲,我创建的一个LinkBut​​ton点击飞的PDF文件。该文件被创建后,我想表明它使用的fancybox(我使用jQuery和的fancybox的第一次)。展示如何做到这一点任何的例子将大大AP preciated。谢谢你。

I want to use the JQuery FancyBox on an asp.net page but all the examples I have found show triggering a fancybox from anchor tag (< a >). I am not able to find an example where a fancybox is triggered from codebehind. To be more specific, I create a pdf file on the fly on a LinkButton click. After the file has been created, I want to show it using fancybox (I am using Jquery and FancyBox for the first time). Any examples showing how to do this will be much appreciated. Thanks.

推荐答案

您的LinkBut​​ton后刷新页面(回发),那么你要注入一些脚本到您的网页。

after your linkbutton refreshes the page (postback), then you want to inject some script into your page.

您页面都应该有这样的事情已经设置

Your page should have something like this already set

<a href="#" id="hidden_link" style="display:none;"></a>
<script type="text/javascript">
    function LaunchFancyBox() { 
          $("#hidden_link").fancybox().trigger('click'); 
    } 
</script>

然后,你会在页面从你的按钮单击处理底部注入一些脚本。

Then you would inject some script at the bottom of the page from your button click handler.

因此​​,在页面的底部,你会加入类似

So at the bottom of your page you will add something like

<asp:Literal runat="server" ID="Literal1" />

然后在你的按钮单击事件处理程序,你将有

Then in your button click event handler you will have

Public Sub Button1_Click()
    Literal1.Text = "<script>$(document).ready(LaunchFancyBox());</script>"
End Sub

他们的博客6号有助于解释这个问题,以及,但他们将推出它在页面加载过时间,所以它们不需要注入脚本。但是,因为你想这样做回发,你需要做的脚本注入位。

no.6 on their blog helps explain this as well, however they're launching it on page load ever time so they don't need to inject the script. But because you want to do it on postback, you need to do the script injection bit.

这篇关于从ASP.Net codebehind触发的fancybox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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