Doesn't work: <td runat =server background="~/Images/Header2.gif">

M

Maxwell2006

Hi,

Using ASP.NET 2.0,

I have this tag in my asp page:

<td runat =server background="~/Images/Header2.gif">&nbsp;</td>

The problem is when I run the page, the server side TD tag renders in this
format in html output:

<td background="~/Images/Header2.gif">&nbsp;</td>

I expect ASP.NET converts "~/Images/Header2.gif" into the actual full path
of the image, but it doesn't do that.

How can I fix the problem?

Thank you,
Max
 
M

Mark Fitzpatrick

It won't since the background attribute is not generally recognized in
modern HTML.

Instead try using background="<%
Response.Write(Request.ApplicationPath);%>/Images/Header2.gif"

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
M

Maxwell2006

Hi Mark,

Thank you for help. Do you suggest using CSS instead of background
attribute? I'll probably have the similar problem in CSS file right?

I have similar problem with body tag:
<body runat =server background="Images/bgr18x18.gif">

What is the proper way do do this?

Thanks again,

Max
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

If you use a CSS file the path of the image is relative to the CSS file,
not relative to the page, so there is no need for the ~ functionality.
 
B

bruce barker \(sqlwork.com\)

thats because ~ path support is handled by .net only for attributes it knows
are urls.

-- bruce (sqlwork.com)
 
M

Maxwell2006

I think my HTML coding is very old fashion!

VS.NET 2005 keeps complain about Validations (XHTML 1.0 Transitional) and
suggest I use newer construct.

Is there any resource/guideline that help me to upgrade my HTML coding
style?

Thank you,
Max
 
W

Walter Wang [MSFT]

Hi Max,

Thank you for your post.

The ASP.NET 2.0 framework was designed to enable you to easily build Web
sites that satisfy Web standards. The framework enables you to easily build
XHTML Web sites. You can find more info here:

#Building ASP.NET 2.0 Web Sites Using Web Standards
http://msdn.microsoft.com/asp.net/reference/design/default.aspx?pull=/librar
y/en-us/dnaspp/html/aspnetusstan.asp

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Maxwell2006

Hi Walter,

The article is exactly what I was looking for. Thanks alot.

Regards,
Max
 
W

Walter Wang [MSFT]

Hi Max,

Appreciate your update and response. If you have any other questions or
concerns, please do not hesitate to contact us. It is always our pleasure
to be of assistance.

Have a nice day!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top