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

Discussion in 'ASP .Net' started by garthb@gmail.com, Mar 11, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Labels always render as <span>s in IE.

    <> wrote in message
    news:...
    > 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
    >
     
    Peter Rilling, Mar 11, 2006
    #2
    1. Advertising

  3. Guest

    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, 2006
    #3
  4. 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

    http://www.nathansokalski.com/

    <> wrote in message
    news:...
    > 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
    >
     
    Nathan Sokalski, Mar 12, 2006
    #4
  5. Guest

    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/library/system.web.ui.webcontrols.label.associatedcontrolid.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, 2006
    #5
  6. Guest

    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, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fulio Open

    Can span include span?

    Fulio Open, Jun 26, 2009, in forum: HTML
    Replies:
    5
    Views:
    581
    dorayme
    Jun 26, 2009
  2. Stéphane Klein
    Replies:
    2
    Views:
    1,870
    John Nagle
    Mar 30, 2010
  3. Stefan Behnel
    Replies:
    0
    Views:
    510
    Stefan Behnel
    Mar 29, 2010
  4. Dan Bishop

    DataGrid (body only) contained in <span>...</span> tags

    Dan Bishop, Jun 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    310
    Kilic Beg
    Jun 7, 2004
  5. Knut Krueger
    Replies:
    8
    Views:
    340
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page