Kᴀτᴢ
Kᴀτᴢ

Reputation: 2176

td background picture asp:Image possible?

I have a given asp.net site in which I change pictures as I need like Image1.ImageUrl = "~/Bilder/B1.png";

These pictures are in table cells as asp.Image.

Is it possible to use these asp:Image as my background for the cell? Something like <td style="background-image:ID('Image1') so that I can change the background as I need through the code?

Upvotes: 1

Views: 160

Answers (1)

meghlashomoy
meghlashomoy

Reputation: 123

See the example below -

Front Page -

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
    <table>
        <tr>
            <td>Test</td>
            <td width="178" rowspan="3" background="<%= s_ImageUrl%>"></td>
        </tr>
    </table>
</div>
</form>
</body>
</html>

Code Behind -

Public Class WebForm1
Inherits System.Web.UI.Page
Public s_ImageUrl As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    s_ImageUrl = "/image/test.jpg"
End Sub

End Class

Now you can change the s_ImageUrl variable to change the image.

Upvotes: 2

Related Questions