issue for background-image in a td tag

A

Adam Right

Hi All,

I have some HTML tags in a .ascx control
If i use style="background-image" in a <td> tag on that ascx control, i can
see the jpg file on design-time but it does not work in run-time for
master-pages..

But if i use same picture in a asp:ImageButton control like
<asp:ImageButton ID="Button1" runat="server"
ImageUrl="~/Images/design/search.jpg" OnClick="Button1_Click"/>

it works fine.

....
The td tag on .ascx file is :
<td
style="width:202;height:34;background-image:url(~/Images/design/search.jpg)"



Any idea how to handle this problem?

Thanks,

Adam
 
J

Jesse Houwing

Hello Eliyahu,
~ is understoos only on server side. Add runat="server" to the td and
the server side should resolve the url correctly.
Is that true for a style tag as well? I never knew that, it would be a pretty
handy feature...

Jesse
 
E

Eliyahu Goldin

You can check it easily. Use a path with the "~" syntax, get the page
rendered in your browser and view the html source. All "~" references should
be replaced with something like ../.. etc. If you see "~", then the path
isn't going to work.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top