views:

159

answers:

1

I have a page called test.aspx and in that page, I have the following link:

<a href="../help/default.aspx?height=100&width=500" 
   class="thickbox">
<asp:ImageButton ID="ibtnHelp" 
                 runat="server" 
                 ImageUrl="~/images/needhelp.jpg" /></a>

When I click on the link, it opens up the default.aspx page under help in a new window instead of the thickbox.

In my masterpage, I have the following in the head for the thickbox:

    <head runat="server">

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"  
            type="text/javascript"></script>

    <script src="../js/thickbox.js" type="text/javascript"></script>

    <title>Details</title>

    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>

    <link href="styles/style.css" rel="stylesheet" type="text/css" />
    <link href="styles/RoundDiv.css" rel="stylesheet" type="text/css" />
    <link href="styles/thickbox.css" rel="stylesheet" type="text/css" />
</head>

If I put it the script directly on the test.aspx, it works fine, but not when I have it in the masterpage.

+1  A: 

First thing to do is ensure the thickbox.js file is being served correctly when linked from the masterpage. Either use firebug or fiddler2 to establish if the file is requested and the response is a 200.

I suspect you need the following to reference thickbox...but its been ages since I had to hack around with aspx..

<script type="text/javascript" src="<%=ResolveUrl("~/js/thickbox.js") %>"></script>
redsquare
Im actually not sure how to do this with firebug? Can you help me out. Thanks
Xaisoft
I can't tell if it is being requested because I am not sure where to look in firebug.
Xaisoft
open firebug, click the net tab, ensure it is enabled then refresh the page. If the file is not requested you will see it in red.
redsquare
here is an example http://gyazo.com/41506238dd304dd6b69d6c27ab795ea5.png
redsquare
Ok, I enabled the net panel and refreshed the page and I actually don't see jquery or thickbox js files there. I see the thickbox.css file though.
Xaisoft
press ctrl+f5 to hard refresh the page. Are you sure you have the all option displayed and not just the css tab
redsquare
yes, I tried to resolveurl and it didn't show and then I tried jquery without the resolve and it showed in the net panel.
Xaisoft
ok, in the net panel now, it is displaying jquery.min.js 304 not modified and below that it is displaying thickbox.js 200 OK
Xaisoft
The above is displayed without using the ResolveUrl method.
Xaisoft
ok so they are both being served correctly. Glad we established that!!
redsquare
looks like it could be working now. Was it just needing to make sure it was being served up correctly. Another question I have is that I know that asp.net changes the id's of controls when using masterpages, so what I have is an anchor with an asp.net image button inside of that. Is this the only way to do it or could I use the asp.net image button with the class thickbox.
Xaisoft
It may have been your page caching event though you had changed the markup...always make sure you ctrl+f5 after a change
redsquare
not sure about your second question....i hate webforms and have not touched it for a good 18months!!
redsquare
cool thanks for the help so far. One other thing if you have the time, In the default.aspx page under help, I have a link, when the thickbox opens, I want to automatically scroll to that link. Do you know how to do that?
Xaisoft
google the scrollTo plugin. It should be possible although thickbox is pretty crap and doesnt have any events for you to hook into when it has shown the dialog
redsquare
Doesn't look like scrollTo can be used to scroll in the thickbox or am I missing something.
Xaisoft
you can use scrollTo in a div that has scroll enabled
redsquare
is your help.aspx loading into an iframe? if so you can use document ready inside the iframe to scrollTo an anchor if you pass the anchor information through the url
redsquare
So in default.aspx I would have a div that is scrollable and use scrollTo to scroll to a certain section? Is that correct?
Xaisoft
Xaisoft