Monday, July 26, 2010

Apply CSS to create Image Border

Sometimes Asp.net developers need to enhance the UI by using image border. Though it's a bit easy in Asp.net image controls by using SKIN to manage image borders but it will be a bit difficult to manage HTML image control without CSS. Here in this post i will show you how one can apply CSS in both Asp.net image control and HTML image control. To do that first write the below CSS:











<style type="text/css">
    .imageCSS
 {
    padding: 3px;
    background-color: #FF0000;
 }
    </style>

Asp.Net Image Control:
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Image ID="Image1" runat="server" CssClass="imageCSS" ImageUrl="images/blue_flower.jpg" />
    </div>
    </form>
</body>

HTML Image Control:
<body>
    <form id="form1" runat="server">
    <div>
        <img src="~/Images/blue_flower.jpg" id="Image2" class="imageCSS" runat="server" />
    </div>
    </form>
</body>

Hope it will help.

No comments:

Post a Comment

Write your Comment: