By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,728 Members | 2,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,728 IT Pros & Developers. It's quick & easy.

asp:Label rendering as <span> in IE :(

P: n/a
Hello,

I have a site which I've been developing locally with VS2k3 Pro. I
have some browsercap information in my web.config to help identify
Firefox as an upscale browser. It works great locally. Labels render
as labels and so on.

However, when deploying the site onto a different server, all my Labels
render as <spans>, even in IE. I don't understand what's going on, I
haven't had this happen to me before. What discrepencies between the
configuration of IIS (or whatever) could exist between my local machine
and the server? As far as I can tell, I've copied everything over to
the server including the web.config with the browsercap info. I might
have expected this to happen with Firefox if I failed to update the
remote web.config, but the fact it's happening with IE is totally
stumping me.

Any ideas as to what's going on?

The Labels render as <span AssociatedControlID="foo">bar</span>. The
local development machine is XP Pro SP2 and the server is Win2k SP4.

Thank you for any advice!

Garth

Mar 11 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Labels always render as <span>s in IE.

<ga****@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
Hello,

I have a site which I've been developing locally with VS2k3 Pro. I
have some browsercap information in my web.config to help identify
Firefox as an upscale browser. It works great locally. Labels render
as labels and so on.

However, when deploying the site onto a different server, all my Labels
render as <spans>, even in IE. I don't understand what's going on, I
haven't had this happen to me before. What discrepencies between the
configuration of IIS (or whatever) could exist between my local machine
and the server? As far as I can tell, I've copied everything over to
the server including the web.config with the browsercap info. I might
have expected this to happen with Firefox if I failed to update the
remote web.config, but the fact it's happening with IE is totally
stumping me.

Any ideas as to what's going on?

The Labels render as <span AssociatedControlID="foo">bar</span>. The
local development machine is XP Pro SP2 and the server is Win2k SP4.

Thank you for any advice!

Garth

Mar 12 '06 #2

P: n/a
Peter, thank you for your response!

Shouldn't Labels render as <label>s if an associated control ID is set?
That's the behaviour I'm used to. The form this is a part of requires
the semantics of a <label> to achieve the required degree of
accessibility.

Anyone else have any suggestions?

Thank you,
Garth

Mar 12 '06 #3

P: n/a
I want to second what you were told the first time, that IE always renders
Labels as Span tags, I don't think I've ever seen them rendered as anything
else. I think that Label Controls are rendered as <span> tags because they
are more generic, therefore allowing ASP.NET to more easily make them look
the way you designed them (this is why you don't see ASP.NET creating tags
such as h1, h2, h3, etc.). If you want a Control to be rendered as a
specific HTML tag, my recommendation would be to create a UserControl that
uses Controls from the System.Web.UI.HtmlControls namespace. I haven't seen
your exact code, so I don't know why you need the code to generate <label>
tags, but in my opinion it is better to stick with <span> because I think it
is more widely supported. Also, if your code "requires" <label> tags (or any
other specific tag), I would recommend looking it over because it sounds
somewhat inefficient, and if you are preventing yourself from using the
built-in Controls such as Label, you will be putting yourself through a lot
of extra work to get less productive results. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<ga****@gmail.com> wrote in message
news:11********************@z34g2000cwc.googlegrou ps.com...
Peter, thank you for your response!

Shouldn't Labels render as <label>s if an associated control ID is set?
That's the behaviour I'm used to. The form this is a part of requires
the semantics of a <label> to achieve the required degree of
accessibility.

Anyone else have any suggestions?

Thank you,
Garth

Mar 12 '06 #4

P: n/a
The merits of using <label>s versus other less "inefficient" tags is a
discussion for another forum, but in the context of this thread I guess
I'm going to have to find another way to generate them. Here is
something interesting I found on MSDN.

===========
http://msdn2.microsoft.com/en-us/lib...ntrolid.aspx):

When the AssociatedControlID property is set, the Label control renders
as an HTML label element, with the for attribute set to the ID property
of the associated control. You can set other attributes of the label
element using the Label properties. For example, you can use the Text
and AccessKey properties to provide the caption and hot key for an
associated control.
===========

The HUGE caveat here is that this page also says it's "new for .Net
2.0"!! I do have 2.0 installed on my machine, but I expected VS2k3 to
continue using 1.1. The easy fix for me to try here, then, is to
install 2.0 on the server...

Thanks for everyones input!

Garth

Mar 12 '06 #5

P: n/a
To close off this thread, I discovered that even though my local
website definition in IIS is set to use .Net 1.1, it's using 2.0. I
verified this by installing 2.0 on the server. The installation of 2.0
didn't solve my problem until I set the website to actually use 2.0,
then Labels rendered as <labels>.

In other words, other than my local IIS apparently not doing what it
should, everything is working as it is supposed to, including have
Label's rendering as <span>s in 1.1 and having them render as <label>s
in 2.0.

Thanks again to Peter and Nathan for kicking me in the right direction!

Garth

Mar 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.