肯定是路徑問題。
頁面是否在不同的目錄中使用主頁面,而這個目錄可能是工作的?
這適用於我。由於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