Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii ,

I am trying to use alternative scene for this scenrio ..

<img src="../../../../images/client_logo.png" />
<link type="text/css" href="../../../../css/PdfTemplateStyle.css" rel="stylesheet" />

I tried with ~/images/client_logo.png

but not working ...

Please suggest as i dont want to go with ../../../../ type of rooting
Posted
Comments
aarif moh shaikh 18-Nov-14 7:52am    
I think ~ (tilled) sign will work .... Please try again
Torakami 18-Nov-14 8:08am    
i tried .. its not working .. not even css not image ... but working with ../

Add runat="server" to your <img> and <link> tags, and app-relative paths will work:
aspx
<img runat="server" src="~/images/client_logo.png" />
<link runat="server" rel="stylesheet" type="text/css" href="~/css/PdfTemplateStyles.css" />

For paths within a CSS file, you can't use app-relative paths. However, the path will always be resolved relative to the CSS file, rather than the containing page, so relative paths are more stable.
 
Share this answer
 
Comments
Torakami 19-Nov-14 0:54am    
Dude , i tried by adding runat=server attribute as well .. still not working ,..
Richard Deeming 19-Nov-14 9:48am    
Then you must be doing something wrong. Adding runat="server" and using an app-relative path has worked in every ASP.NET WebForms project I've ever seen.

Load the page in the browser and view the source to see what path the server has rendered.
i think you are asking for the website application in asp.net.
then,
you can use...
C#
<link rel="stylesheet" type="text/css" href="~/Full_path_of_the_File/file.css" />
here ~ indicates the root path of the solution.


or you can just use this in your asp.net application like..
add your site url path to the web.config file..
C#
<appSettings>
   <add key="Site_Url" value="http://localhost:12018/"/>
 </appSettings>

and used it like..
C#
<link href="<%=ConfigurationManager.AppSettings[" site_url="] %>css/base.css" rel="stylesheet" />
 
Share this answer
 

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



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