Here is the setup for my control:
<asp:HyperLink CssClass="link-image" ID="Link1" runat="server"/>
Code-behind in C#:
Link1.ImageUrl = "imagePath";
Resulting HTML code:
<a class="link-image" id="MainContent_Link1">
<img alt="" src="\Images\Advertising\ImageFile1.jpg">
</a>
Description of my CSS:
.link-image {
display: block;
margin-left: auto;
margin-right: auto;
}
Although the CSS class works when applied to the img
element, the control can only assign the class to the a
element.
I am attempting to avoid the use of JavaScript if at all possible.