使用 asp.net ClientScript 时不显示 Facebox 图像

发布于 2024-10-25 21:00:15 字数 1507 浏览 2 评论 0原文

我在 ASP.net 项目中使用 FaceBox。当我从 ASPX 页面中的硬编码脚本块调用它时,效果很好,如下所示:

<script type="text/javascript">

    jQuery(document).ready(function($) {
        $('a[rel*=facebox]').facebox({
            loadingImage: '../../CSS/FaceBox/Images/loading.gif',
            closeImage: '../../CSS/FaceBox/Images/closelabel.png'
        })
    });
</script>

但是,当我将该代码移动到代码后面以便我可以首先执行一些服务器端代码时,该框打开得很好,但图像是不再显示(而是显示缺失图像图标。单击该图标确实有效。)。这是我正在使用的代码:

Dim sbClientScript As System.Text.StringBuilder = New System.Text.StringBuilder()

sbClientScript.AppendLine("<script type='text/javascript'>")
sbClientScript.AppendLine("  jQuery.facebox({                                                   ")
sbClientScript.AppendLine("      ajax: 'EditQuestion.aspx',                                     ")
sbClientScript.AppendLine("      loadingImage: '../../CSS/FaceBox/Images/loading.gif',          ")
sbClientScript.AppendLine("      closeImage: '../../CSS/FaceBox/Images/closelabel.png'          ")
sbClientScript.AppendLine("    });                                                              ")
sbClientScript.AppendLine("</script>")

    If Not Page.ClientScript.IsStartupScriptRegistered("skFacebox") Then
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "skFacebox", sbClientScript.ToString())
    End If

我尝试更改参数的顺序(将“ajax”放在最后)。我尝试过将事情分成不同的功能。我尝试在硬编码脚本块中设置loadingImage和closeImage。什么都不起作用。

有人知道设置图像参数的正确语法吗?

谢谢!

I'm using FaceBox in an ASP.net project. It works great when I call it from a hard-coded script block in the ASPX page like this:

<script type="text/javascript">

    jQuery(document).ready(function($) {
        $('a[rel*=facebox]').facebox({
            loadingImage: '../../CSS/FaceBox/Images/loading.gif',
            closeImage: '../../CSS/FaceBox/Images/closelabel.png'
        })
    });
</script>

However, when I move that code into code behind so that I can first execute some server side code, the box opens great but the images are no longer displayed (the missing image icon is displayed instead. Clicking the icon does work.). Here's the code I'm using:

Dim sbClientScript As System.Text.StringBuilder = New System.Text.StringBuilder()

sbClientScript.AppendLine("<script type='text/javascript'>")
sbClientScript.AppendLine("  jQuery.facebox({                                                   ")
sbClientScript.AppendLine("      ajax: 'EditQuestion.aspx',                                     ")
sbClientScript.AppendLine("      loadingImage: '../../CSS/FaceBox/Images/loading.gif',          ")
sbClientScript.AppendLine("      closeImage: '../../CSS/FaceBox/Images/closelabel.png'          ")
sbClientScript.AppendLine("    });                                                              ")
sbClientScript.AppendLine("</script>")

    If Not Page.ClientScript.IsStartupScriptRegistered("skFacebox") Then
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "skFacebox", sbClientScript.ToString())
    End If

I've tried changing the order of the parameters (putting "ajax" last). I've tried splitting things out into different functions. I've tried setting the loadingImage and closeImage in a hard coded script block. Nothing is working.

Anyone know the correct syntax to set the image parameters?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

滴情不沾 2024-11-01 21:00:15

感谢 Firebug 和一些尝试和错误,我想出了正确的语法和顺序:

sbClientScript.AppendLine("jQuery.facebox.settings.loadingImage = '../../CSS/FaceBox/Images/loading.gif',")
sbClientScript.AppendLine("jQuery.facebox.settings.closeImage = '../../CSS/FaceBox/Images/closelabel.png'")
sbClientScript.AppendLine("<script type='text/javascript'>")
sbClientScript.AppendLine("  jQuery.facebox({")
sbClientScript.AppendLine("      ajax: 'EditQuestion.aspx'")
sbClientScript.AppendLine("    });")
sbClientScript.AppendLine("</script>")

Thanks to Firebug and some trial and error I came up with the correct syntax and ordering:

sbClientScript.AppendLine("jQuery.facebox.settings.loadingImage = '../../CSS/FaceBox/Images/loading.gif',")
sbClientScript.AppendLine("jQuery.facebox.settings.closeImage = '../../CSS/FaceBox/Images/closelabel.png'")
sbClientScript.AppendLine("<script type='text/javascript'>")
sbClientScript.AppendLine("  jQuery.facebox({")
sbClientScript.AppendLine("      ajax: 'EditQuestion.aspx'")
sbClientScript.AppendLine("    });")
sbClientScript.AppendLine("</script>")
时光是把杀猪刀 2024-11-01 21:00:15

尝试

<%="~/CSS/FaceBox/Images/loading.gif"%> instead of '../../CSS/FaceBox/Images/closelabel.png' 

Try

<%="~/CSS/FaceBox/Images/loading.gif"%> instead of '../../CSS/FaceBox/Images/closelabel.png' 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文