MasterPages came with ASP.NET 2.0 and it's very useful. If you are using master pages, JavaScript files, images, links and sub folders in own projects. This article is very useful for you.
For example you insert image in your master page and create an aspx file in subfolder.
In master page : <img src="Images/mustafaozcanblog.png" alt="Mustafa ÖZCAN's Blog" />
Sample.aspx file is in samples folder and it is use master page in root folder. Added images cannot be displayed in rendered sample.aspx page because images folder in root folder but samples.aspx page search it in samples directory.
So you have two ways solution for this problem:
1st Way: You must change this line for added image :
<img src="~/Images/mustafaozcanblog.png" alt="Mustafa ÖZCAN's Blog" runat="server"/>
2nd Way: You must change this line for added image :
<img src='<%=ResolveUrl("~/Images/mustafaozcanblog.png")%>' alt="Mustafa ÖZCAN's Blog" />
You can use 2nd Way to added JavaScript files and other external content in master page file.
2225 times displayed