Image Control Notes:
O controlo Image disponibiliza um conjunto de operações que não são possiveis com a tag "img" normal de HTML. Um exemplo é possibilidade de utilizar endereços relativos de forma bastante flexivel em vez de endereços absolutos (while hard coding in the absolute URL works, it tightly couples your HTML to the website's server and folder location, which may change):
Keep in mind that only ASP.NET server controls transform the ~ in their URL-related properties. If a ~ appears in static HTML markup, such as <img src="~/Images/PoweredByASPNET.gif" />, the ASP.NET engine sends the ~ to the browser along with the rest of the HTML content. The browser assumes that the ~ is part of the URL. For example, if the browser receives the markup <img src="~/Images/PoweredByASPNET.gif" /> it assumes there is a subfolder named ~ with a subfolder Images that contains the image file PoweredByASPNET.gif.
To fix the image markup in Site.master, replace the existing <img> element with an ASP.NET Image Web control. (article)Problema:
ASP.NET Image control automaticly renders images with no border: an inline style attribute with "border-width to 0px" is set on the rendered images. This brings issues with CSS control over this images.
It's silly but whoever in Microsoft wrote the render method of that control decided to put a style="border-width:0px;" as a default.
Soluções:
Use the
"runat=server" method on a normal html image:<img runat=server src=~/somefile.gif> o "~" será transformado automaticamente na pasta root (tal como no controlo Image);Ou criar uma nova class que modifique este comportamento do controlo Image: tal como demostrado neste artigo.
No comments:
Post a Comment