Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I have My all CSS and Java scripts links are in Master Page, and rewriting Url Using Application_BeginRequest.

URL:

localhost:49296/SiteName/12/ProductName

to

localhost:49296/SiteName/Post.aspx?id=12


In Post.aspx Images and JS are not available !

CSS is working properly-

<link href="~/css/style.css" rel="stylesheet" type="text/css" />

but JQuary is gone :

<script type="text/javascript" src="script/jquery.leanModal.min.js"></script>


Please help
Posted
Updated 13-Mar-15 8:46am
v2

1 solution

Try:
HTML
<script type="text/javascript" src="<%= Page.ResolveUrl("~/script/jquery.leanModal.min.js") %>"></script>
 
Share this answer
 
Comments
Pr!y@ 13-Mar-15 15:00pm    
Sir it is working but is it good to use this in all the content ?

any issue in performance because now i have to change my all link to this ?
Richard Deeming 13-Mar-15 15:04pm    
It's unlikely to cause any noticeable performance problems. However, you can't use it for properties of server controls - anything with runat="server", and any <link> tags in the page header.
Pr!y@ 13-Mar-15 15:09pm    
Sir is there any other option because I have a lot of links in Master Page... and some are dynamic
Richard Deeming 13-Mar-15 15:16pm    
You can either use an app-relative URL (~/script/...) or an absolute URL (/SiteName/script/...).

If you use an absolute URL, then you'll need to change it whenever you deploy your application - it could end up as /SiteName2/script/... or /script/..., etc.

To use an app-relative URL, the tag needs to be a server control.

You can't add runat="server" to the <script> tag, as that will be interpreted as a server-side script.

Therefore, you need to use the syntax I have shown, or create your own custom control to render a script tag with support for an app-relative URL.

Otherwise, you would have to remove all <script> tags and register them from the code-behind:
ClientScriptManager.RegisterClientScriptInclude Method[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900