ASP Label control render problem to Firefox

Last post 08-16-2007 2:14 PM by ajwaka. 9 replies.

Sort Posts:

  • ASP Label control render problem to Firefox

    09-12-2006, 7:19 PM
    • Loading...
    • avida
    • Joined on 09-17-2005, 3:07 PM
    • Posts 38

    Hi,

     I've setup a theme and in it have a couple of different label controls. e.g.

    <asp:Label Runat="server" font-names="verdana" width="100px" skinid="rs100" cssclass="rightalign"/>

    and a CSS of

    .rightalign {text-align:right;}

    so all simple stuff

    On IE 6 this all displays great, All my labels are right aligned for a standard width and line up perfectly.

    However on firefox this does not work. On futher inspection it seems that ASP.net automatically renders this with

    a <span> and display:inline-block which IE 6 is happy with but Firefox doesn't handle.

    So the question is - How do I get ASP to render so it works both on IE 6 and Firefox.

    Thanks.

    Filed under: , , ,
  • Re: ASP Label control render problem to Firefox

    09-12-2006, 7:51 PM
    • Loading...
    • LudovicoVan
    • Joined on 12-02-2004, 3:01 PM
    • Hic abundant leones!
    • Posts 1,714

    The problem seems instead that width doesn't want a unit of measure, so should be width="100". Firefox is a bit more "strict" about syntax.

    Hope this helps. -LV

    Julio Di Egidio
    Analyst Programmer
    http://julio.diegidio.name

    (Peace X Love] = [++1)
  • Re: ASP Label control render problem to Firefox

    09-13-2006, 5:46 AM
    • Loading...
    • avida
    • Joined on 09-17-2005, 3:07 PM
    • Posts 38

    Thanks for that. But it does seem to be a problem with FireFox not recognising the CSS display:inline-block .

    This does seem to be correct behaviour for Firefox. However I dont have control over the way the ASP Label tag is rendered.

    So does this mean that

    the Width property of the Label control cannot be used when cross browser compatibility is an issue

    or

    is there a setting that makes the Label control emit cross browser compatible HTML / CSS.

    Thanks

     

  • Re: ASP Label control render problem to Firefox

    09-13-2006, 6:36 AM
    Answer
    • Loading...
    • LudovicoVan
    • Joined on 12-02-2004, 3:01 PM
    • Hic abundant leones!
    • Posts 1,714

    .NET at the base renders XHTML conforming code. Then it is up to the developer...

    Indeed, display:inline-block does not exist at all. It is either inline, or block, or none, etc.

    And width, by standard, wants a number, and you shouldn't be putting "px" there.

    -LV

    Julio Di Egidio
    Analyst Programmer
    http://julio.diegidio.name

    (Peace X Love] = [++1)
  • Re: ASP Label control render problem to Firefox

    09-13-2006, 7:00 AM
    • Loading...
    • avida
    • Joined on 09-17-2005, 3:07 PM
    • Posts 38

    Hi,

    You are quite correct about the px. I will remove that. Thanks.

    However, ASP does render the Label with display:inline-block (not me the developer) .

    (see: http://www.quirksmode.org/css/display.html )

    So I think its back to nasty tables :)

    Many thanks

  • Re: ASP Label control render problem to Firefox

    09-13-2006, 7:08 AM
    Answer
    • Loading...
    • LudovicoVan
    • Joined on 12-02-2004, 3:01 PM
    • Hic abundant leones!
    • Posts 1,714

    Wow! Didn't know about that.

    That's why, apart from grids and similar "special" controls, I only only use html controls...

    Actually, they make the separation of client- vs server-side quite more natural, and that's another major reason.

    -LV

    Julio Di Egidio
    Analyst Programmer
    http://julio.diegidio.name

    (Peace X Love] = [++1)
  • Re: ASP Label control render problem to Firefox

    01-25-2007, 7:55 AM
    • Loading...
    • camera
    • Joined on 07-27-2006, 5:05 PM
    • Austin
    • Posts 44
    Try wrapping the label in a DIV tag with class "rightaligndiv" and then use the CSS .rightaligndiv { text-align: right } This should push all the labels to the right -- regardless of whether they are right aligned in the label or not. worth a shot...
    Vine Type: Content Management with Standards in Mind. http://vinetype.com
    Filed under:
  • Re: ASP Label control render problem to Firefox

    03-22-2007, 5:26 AM
    • Loading...
    • BGM
    • Joined on 01-21-2007, 6:15 PM
    • Guildford, UK
    • Posts 37

    You could put span tags around the offending elements that keep moving where they shouldnt

    e.g.

    <span class="formLabel"><asp:Label ID="lblJobTitle" runat="server" Text="Job Title:"></asp:Label>
     
    Then define the formLabel css
    e.g.
    .formLabel { width: 120px; float: left; }
     
    I don't know a way of specifying it any my 'automatically' (in a theme) then this im afraid, but this way the result will be the same in FF and IE
     
    regards
    Chris 
      
     
     
  • Re: ASP Label control render problem to Firefox

    03-22-2007, 8:51 AM

    asp:Label controls typically don't emit the display:inline-block Style, you may want to check your associated Skin (skinid="rs100") to make sure it's not inserting things into the Style or removing the Width attribute (width="100px") from your Label - ASP.NET might automagically render the style (display:inline-block) when a width is associated to a Label.

    asp:Label controls emit a SPAN tag which is an Inline CSS Element - a DIV or Table is a Block Element. I don't think the W3C CSS Standards provide a mechanism for setting the width on Inline Elements (like asp:Label, the span) because you'd typically use a Block type Element, like a Div, or turn your Span into a block element (display: block;).

    A couple alternatives you could try:

        Try using the asp:Literal in place of the asp:Label

        Try wrapping your asp:Label in a Div then set the width and align settings on the Div 

        Try removing [font-names="verdana" width="100px" skinid="rs100"] from your asp:Label and add the following to your CSS file:

    .rightalign {
        text-align: right;
        display: block;
        width: 100px
     } 

     

    Safari 2.0.3., Konqueror 3.5, Opera 9 and Mozilla Firefox are very W3C CSS Standard compliant, however Internet Explorer is not. If you do your CSS / Design development in one of these more standard compliant browsers you'll pleasantly discover that your Design is more cross browser compatible - this often reduces debug time.

  • Re: ASP Label control render problem to Firefox

    08-16-2007, 2:14 PM
    • Loading...
    • ajwaka
    • Joined on 05-17-2005, 3:12 PM
    • Wisconsin
    • Posts 50
    Adam - Great tip!  Never thought about that.  Works for me!
    Relax and have some Home Brew!
    Prosecute the Owner - Don't PERSECUTE the Breed!
    Breed Specific Legislation targets the WRONG end of the LEASH!
Page 1 of 1 (10 items)
Microsoft Communities
Page view counter