Posts

Showing posts from July, 2006

Master Page and Content Page Path in ASP.NET

I ran into this problem that i wanted to share.
i have a master page that i use in a content page but the content page is not in the same directory as the master page.
My master page contains "img" elements, when I browsed to the content page those images weren't displayed because they have invalid path.
I found the solution on the MSDN Site

"ASP.NET cannot modify URLs on elements that are not server controls. For example, if you use an img element on a master page and set its src attribute to a URL, ASP.NET will not modify the URL. In that case, the URL will be resolved in the context of the content page and create the URL accordingly.
In general, when working with elements on master pages, it is recommended that you use a server control, even for elements that do not require server code. For example, instead of using an img element, use an Image server control. That way, ASP.NET can resolve URLs correctly and you can avoid maintenance issues that might arise if you mov…