肯定是路径问题。
页面是否在不同的目录中使用主页面,而这个目录可能是工作的?
这适用于我。由于javascript是在代码后面生成的,因此可以使用波浪符号来解析正确的路径。
检查http://www.zedesigns.com/Showroom.aspx看到它在行动。
protected void InsertLightbox()
{
if (!Page.ClientScript.IsClientScriptIncludeRegistered("jquery-latest.pack.js"))
Page.ClientScript.RegisterClientScriptInclude("jquery-latest.pack.js", "http://code.jquery.com/jquery-latest.pack.js");
if (!Page.ClientScript.IsClientScriptIncludeRegistered("jquery.lightbox.js"))
Page.ClientScript.RegisterClientScriptInclude("jquery.lightbox.js", System.Web.VirtualPathUtility.ToAbsolute("~/js/jquery.lightbox.js"));
if (!Page.ClientScript.IsClientScriptBlockRegistered("lightbox"))
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.AppendLine("$(document).ready(function(){");
sb.AppendFormat("$('.lightbox').lightbox({{fileLoadingImage:'{0}',fileBottomNavCloseImage:'{1}',fitToScreen:true}});", Page.ResolveClientUrl("~/images/lightbox/loading.gif"), Page.ResolveClientUrl("~/images/lightbox/closelabel.gif"));
sb.AppendLine("});");
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "lightbox", sb.ToString(), true);
}
Helpers.Page.AddStyleSheet(this, "~/styles/lightbox.css", "screen");
}
什么是错误信息? – Marco 2009-11-16 12:39:18
看到这个问题:如何在Master Pages中使用JQuery? - http://stackoverflow.com/questions/292787/how-to-use-jquery-with-master-pages – Phaedrus 2009-11-16 14:35:55