hi
1) With Html elements that don’t have runat = “server” attribute, absolute and relative paths are sent to the browser as they are. But with server controls, Asp.Net runtime provides URL rebasing feature, where URLs ( specified by server controls contained inside Master Pages, Themes or User Controls ) relative to Master pages, Themes or User Controls are dynamically modified so that browser can locate referenced resources using URLs relative to the final page sent to the browser.
a) Besides master pages, themes and user controls, are there any other situations where URL rebasing feature is needed?
2) Assuming test.aspx is located in the root of a web application ( WebApp20/test.aspx ), while image file is located at WebApp20/Images/award.gif, then in the final page sent to the browser both of the following URLs will resolve to src=”Images/award.gif”.
test.aspx:
<img id="A" src="Images/award.gif" alt="image" runat="server" />
<br>
<img id="B" src= "~/Images/award.gif" alt="image” runat="server" />
While I understand that “~” is resolved by Asp.Net to the root of current web application and I also see the benefits of using it in certain situations, in the example above control B doesn’t really need it to find an image, and thus B could instead have src="Images/award.gif". And yet I’ve seen quite a few code examples where programmers used "~/Images/award.gif" instead of "Images/award.gif".
a) So is there a particular reason why in the example above we should prefer using "~/Images/award.gif" instead of "Images/award.gif"?
thanx