Results 1 to 7 of 7

Thread: Why does .NET leave out style tags?

  1. #1

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50

    Question Why does .NET leave out style tags?

    Why does .NET leave out style tags for non-IE browsers?

    I made a label and dropdown box in ASP.NET (been coding VB.NET for a while, just branching into ASP.NET now) and I've noticed that ASP.NET leaves out style tags on browsers that are not IE.

    Here's an example of code generated by the same page:
    Code:
    IE:
    <span id="_ctl0_lblLabel_2" style="width:100px;">Non-Leavers</span>
    
    Mozilla:
    <span id="_ctl0_lblLabel_2">Non-Leavers</span>
    The same happens with tables borders and various other things

    I would manually change the code in the designer but it has this wonderful habit of chaging any style tags I put it to match actual properties.

    I don't want to be defining widths in my style sheets otherwise they will become needlessly oversized.

    Is there some kind of setting I'm missing to get these tags generated for non-IE browsers?
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131
    I think .NET generally assumes everything but IE is a downlevel browser. I found the following to my web.config file within system.web to allow additional functions to be used in other browsers.

    Code:
    <browserCaps>
          		<case match="Gecko/[-\d]+">
            		browser=Netscape
            		frames=true
            		tables=true
            		cookies=true
            		javascript=true
            		javaapplets=true
            		ecmascriptversion=1.5
            		w3cdomversion=1.0
            		css1=true
            		css2=true
            		xml=true
            		tagwriter=System.Web.UI.HtmlTextWriter
            		<case match="rv:1.0[^\.](?'letters'\w*)">
              			version=6.0
              			majorversion=6
              			minorversion=0
              			<case match="^b" with="${letters}">
                		beta=true
              			</case>
            		</case>
            		<case match="rv:1(\.\d+)(\.\d)?(?'letters'\w*)">
              			version=7.0
              			majorversion=7
              			minorversion=0
              			<case match="^b" with="${letters}">
                			beta=true
              			</case>
            		</case>
          		</case>
    			<case match="Opera">
                	browser=Opera
    				version=${version}
    				majorversion=${major}
                    minorversion=${minor}
                    frames=true
                    tables=true
                    cookies=true
                    javascript=true
                    ecmascriptversion=1.3
                    css1=true
                    css2=true
                    xml=true
                    w3cdomversion=1.0
                </case>
        	</browserCaps>
    Dunno if that will help you.

    DJ

  3. #3

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50
    Thanks, I'll give that a try.
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  4. #4

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50

    It didn't work

    Sorry for delay in replay, been called to different non-.NET projects for a couple of days.

    I put that code into my web.config file within the system.web and it didn't change anything. The style tags are still being ignored.

    Thanks though.
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  5. #5
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131
    Post the server-side code you are using to generate the tags.

  6. #6

    Thread Starter
    Member DDfunbags's Avatar
    Join Date
    Aug 2001
    Location
    Isle of Wight, England
    Posts
    50
    It's just using the regular Width properties of the text box or label controls eg:
    Code:
    <asp:Label id="Label1" runat="server" Width="150px">Label</asp:Label>
    <asp:TextBox id="TextBox1" runat="server" Width="300px"></asp:TextBox>
    The HTML generated on IE is:
    Code:
    <span id="_ctl0_Label1" style="width:150px;">Label</span>
    <input name="_ctl0:TextBox1" type="text" id="_ctl0_TextBox1" style="width:300px;" />
    See how .NET puts a style="width:300px;" for IE for the text box and style="width:150px;" for the label

    The code generated for Mozilla is:
    Code:
    <span id="_ctl0_Label1">Label</span>
    <input name="_ctl0:TextBox1" type="text" id="_ctl0_TextBox1" />
    It completely ignores the Width settings and leaves out the style tag. The same occures on Opera.

    The same will happen with borders around ASP.NET Tables. You define a width and a colour and .NET will impliment the styles for IE and not for Mozilla and Opera etc..


    I am looking into this <browsercaps> configuration as this seems to be the way to go according to MSDN and a couple of other sites. At the moment it's not working though. If I get it working, I'll post.
    I ain't the best coder,
    I ain't the worst coder

    Messanger Handle : FBz

  7. #7
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131
    I honestly hadn't noticed that it did that for textboxes!

    I would have thought it was more of a browserCaps issue than a bug in the .NET framework.

    If you do find a solution I'd like to know!

    Cheers

    DJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width