prettyPhoto不适用于ASP.NET URL路由

时间:2015-05-24 19:00:33

标签: c# asp.net prettyphoto asp.net-routing

我在我的asp.net项目中使用了prettyPhoto。我有一些问题。 当我在我的项目中使用url路由时,prettyPhoto不起作用。在_self target上打开图像(它看起来不像弹出窗口) 如果我不使用路由它可以正常工作。

你知道吗?您可以在下面看到我的示例代码。

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

当光标在我的图片上时,网址似乎为

 example.com/images/image1.jpg`

它的工作

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

它不起作用

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

1 个答案:

答案 0 :(得分:1)

我的脚本标签如下所示。

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

因此,脚本(因为网址路由)被下面的目录

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

脚本必须如下:

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