0

I am using LightBox v2.0.4 with master pages on a web site and I am having problems with the loading.gif and closelabel.gif images appearing. In lightbox.js, whenever I run the program it gives error in this line

 fileLoadingImage:       
'images/loading.gif',     
 fileBottomNavCloseImage: 'images/closelabel.gif',

But if run the above application with out using master page every thing works fine with no issue. Whenever we implement with Master page we get a javascript error. Have any one got this type of error? How did you solve it?

Any help would be great.

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
happysmile
  • 7,537
  • 36
  • 105
  • 181
  • See this question: How to use JQuery with Master Pages? - http://stackoverflow.com/questions/292787/how-to-use-jquery-with-master-pages – Phaedrus Nov 16 '09 at 14:35

2 Answers2

0

What's the actual error? We can't help without that.

As a first step, debug your page using Firebug or similar -- for example, this will show if the specified image path is invalid (you will get a 404 in the net console).

Ben
  • 7,548
  • 31
  • 45
  • i get an error telling image is not found at this line in lightbox.js script file LightboxOptions = Object.extend({ fileLoadingImage: 'images/loading.gif', fileBottomNavCloseImage: 'images/closelabel.gif', – happysmile Nov 16 '09 at 18:00
0

Must surely be a paths issue.

Is the page using the masterpage in a different directory that the one which works maybe?

This works for me. As the javascript is generated in the code behind it can use the tilde notation to resolve the correct path.

Check http://www.zedesigns.com/Showroom.aspx to see it in action.

 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");
    }
Mark Holland
  • 846
  • 4
  • 8