使用 asp.net ClientScript 时不显示 Facebox 图像
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢 Firebug 和一些尝试和错误,我想出了正确的语法和顺序:
Thanks to Firebug and some trial and error I came up with the correct syntax and ordering:
尝试
Try