Adding image from code behind

S

Shawn

Hi.
I have an asp:table, like this:

<asp:Table runat="server" id="Table1">
<asp:TableRow Runat="server">
<asp:TableCell id="tc1" Runat="server">&nbsp;</asp:TableCell>
<asp:TableCell id="tc2" Runat="server">&nbsp;</asp:TableCell>
</asp:TableRow>
</asp:Table>

How can I add a background image to the TableCells from code behind?

Thanks,
Shawn
 
E

Eliyahu Goldin

Shawn,

Make a css style with atribute background-image set to your image. Set
CssClass property for TableCell into the style name.

Eliyahu
 
S

Shawn

Thanks for quick answer!

The thing is that the background image is an embedded resource so I don't
think I can't use that method.
Do you know of another way?

Thanks,
Shawn
 
E

Eliyahu Goldin

One second. Whatever place your image is in on the server, the client can
get it only by url. So you have to provide the client with the url to the
image. It doesn't mean you have to export the image in a separate file. You
can make a page that will accept an image id as a parameter, get the image
from the resource and then stream it down to the client, in the way how
database-stored images get sent to clients. But as far as table cell setting
is concerned, you should do it in the way I suggested. The css rule can look
like

background-image : "getImage.aspx?id=1";

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top