简体   繁体   中英

prettyPhoto doesn't work with ASP.NET URL routing

I'm using prettyPhoto in my asp.net project. I have some issue. When i use url routing in my project, prettyPhoto doesn't work. Image opening on _self target (It doesn't seem as popup) If i don't use routing it's working fine.

Do you have any idea? You can see my sample code below.

Global.asax

 void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("Details","Details/{Detail}/{Title}","~/Detail.aspx");               
    }

    protected void Application_Start(object sender, EventArgs e)
    { 
        RegisterRoutes(RouteTable.Routes);
    }

Page Url

http://example.com/Details/SampleDetail/SampleTitle

When the cursor on my image, url seems as

 example.com/images/image1.jpg`

It's working

<a href='<%#Eval("ImageUrl") %>'  rel="prettyPhoto[myImageGroupName]" title="Some Text"/>

It doesn't work

<a href='<%# Page.ResolveUrl(Eval("ImageUrl").ToString()) %>'  rel="prettyPhoto[myImageGroupName]" title="Some Text"/>

My script tags were like below.

<script src="js/jquery-1.3.2.min.js"></script>
<script src="js/jquery.prettyPhoto.js" type="text/javascript"></script>

So scripts (because of url routing) were searched by below directory

/example.com/Details/SampleDetail/SampleTitle/js/jquery.prettyPhoto.js ...

Scripts must be as follows:

<script src='<%= Page.ResolveUrl("~/js/jquery-1.3.2.min.js") %>'></script>
 <script src='<%= Page.ResolveUrl("~/js/jquery.prettyPhoto.js") %>' type="text/javascript"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM