ASP.NET is "butchering" my code

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default ASP.NET is "butchering" my code

    Hi

    I have two machines, one running Win 2000 and VS.NET 2002, and one running
    Mac OS 10.2.

    I can develop web apps on my Windows machine, and look at them in IE, and
    they look fine. But if I try to view my pages in Safari (Apple's web
    browser) on my Mac, there are various formatting problems. I've investigated
    what's happening and it seems that ASP.NET is discriminating against Safari
    (and other browsers).

    For testing, I set up a simple ASP.NET page with a single TextBox on it,
    which I resized. It uses the following line of code:

    <asp:textbox Height="50" ID="TextBox1" runat="server" TextMode="MultiLine"
    Width="350" />

    Now, I can open the resulting page using IE, and if I look at the HTML code
    generated by ASP.NET (by using View Source), the line responsible for
    drawing the TextBox is:

    <textarea name="TextBox1" id="TextBox1"
    style="height:50px;width:350px;"></textarea>

    That line contains all the code necessary to draw the TextBox to the size I
    want, and displays fine in IE. However, opening the same page in Safari and
    looking at the source, I see this code:

    <textarea name="TextBox1" id="TextBox1"></textarea>

    Huh? Where's all the sizing information gone? The TextBox sizes itself to
    whatever the default is, which is nowhere near as large as what I want it to
    be. Well maybe Safari isn't capable of drawing the TextBox to the required
    size? But I've checked this out too, and that's not the problem. By enabling
    the debugging functions in Safari, there's now an option for changing the
    user agent and pretending you're a different browser. So I set the user
    agent to IE6 on Windows, and voila, the TextBox now appears the correct size
    in Safari. I looked at the various user agents available in Safari (Mozilla
    1.1, Netscape 7.0, Netscape 6.2.2, Netscape 4.79, Mac IE 5.22, Windows IE
    6.0, and Konqueror 3), and all of those user agents, which the exception of
    the IE ones, receive this "butchered" code.

    I proceeded to open up my "proper" site, which is loaded with controls and
    formatting problems, set Safari's user agent to IE6 for Windows, and the
    site appears almost perfectly! Most of the formatting problems I was having
    have completely disappeared.

    So my question is, why is ASP.NET removing all the formatting code if the
    browser isn't IE, and most importantly, how do I stop it from doing this?

    Thanks
    Chris


    Chris Mahoney Guest

  2. Similar Questions and Discussions

    1. Proj cannot run on LCDS 2.6 ES due to "Unable to resolveresource bundle "datamanagement" for locale "en_US"
      hi, all, We have developped an application on Flex Build 3 (run successfully), but failed when we try to deploy it on Tomcat with LCDS 2.5 ES...
    2. CFINPUT type="radio" w/ "value" requires "label"
      On a Flash form, when you specify type='radio' and value='whatever', the value of the 'value' attribute will be displayed as a label if no 'label'...
    3. <tr id="MyRow" runat="server"> ... </tr> doesn't appear in server-side code
      pschrader: Look at the top of your page, where your controls are declared. Do you see one for HTMLTableRow? You may have to manually add it, if...
    4. Need Code for "Print This Page" "Print This Table"
      I need the code for "Print This Page" and especially for "Print This Table." I want to put this as a "link" from my main page. As is, if I...
    5. "Start" "Program" "Menu" list is empty
      For what ever reason my list of installed programs in my "Start" "Programs" menu is empty. Anyone know how to restore the list. Thanks for your...
  3. #2

    Default Re: ASP.NET is "butchering" my code

    Yes, ASP.NET tries to be smart and not send any HTML to a browser that it's
    not sure that browser can handle.
    There are ways to deal with these kinds of issues.
    For instance, try some code like this to set your field width:

    MyTextBox.Attributes.Add("style", "width:350px;")

    --
    I hope this helps,
    Steve C. Orr, MCSD
    [url]http://Steve.Orr.net[/url]



    "Chris Mahoney" <chrismahoney@paradise.net.nz> wrote in message
    news:uCzbSLCTDHA.3144@tk2msftngp13.phx.gbl...
    > Hi
    >
    > I have two machines, one running Win 2000 and VS.NET 2002, and one running
    > Mac OS 10.2.
    >
    > I can develop web apps on my Windows machine, and look at them in IE, and
    > they look fine. But if I try to view my pages in Safari (Apple's web
    > browser) on my Mac, there are various formatting problems. I've
    investigated
    > what's happening and it seems that ASP.NET is discriminating against
    Safari
    > (and other browsers).
    >
    > For testing, I set up a simple ASP.NET page with a single TextBox on it,
    > which I resized. It uses the following line of code:
    >
    > <asp:textbox Height="50" ID="TextBox1" runat="server" TextMode="MultiLine"
    > Width="350" />
    >
    > Now, I can open the resulting page using IE, and if I look at the HTML
    code
    > generated by ASP.NET (by using View Source), the line responsible for
    > drawing the TextBox is:
    >
    > <textarea name="TextBox1" id="TextBox1"
    > style="height:50px;width:350px;"></textarea>
    >
    > That line contains all the code necessary to draw the TextBox to the size
    I
    > want, and displays fine in IE. However, opening the same page in Safari
    and
    > looking at the source, I see this code:
    >
    > <textarea name="TextBox1" id="TextBox1"></textarea>
    >
    > Huh? Where's all the sizing information gone? The TextBox sizes itself to
    > whatever the default is, which is nowhere near as large as what I want it
    to
    > be. Well maybe Safari isn't capable of drawing the TextBox to the required
    > size? But I've checked this out too, and that's not the problem. By
    enabling
    > the debugging functions in Safari, there's now an option for changing the
    > user agent and pretending you're a different browser. So I set the user
    > agent to IE6 on Windows, and voila, the TextBox now appears the correct
    size
    > in Safari. I looked at the various user agents available in Safari
    (Mozilla
    > 1.1, Netscape 7.0, Netscape 6.2.2, Netscape 4.79, Mac IE 5.22, Windows IE
    > 6.0, and Konqueror 3), and all of those user agents, which the exception
    of
    > the IE ones, receive this "butchered" code.
    >
    > I proceeded to open up my "proper" site, which is loaded with controls and
    > formatting problems, set Safari's user agent to IE6 for Windows, and the
    > site appears almost perfectly! Most of the formatting problems I was
    having
    > have completely disappeared.
    >
    > So my question is, why is ASP.NET removing all the formatting code if the
    > browser isn't IE, and most importantly, how do I stop it from doing this?
    >
    > Thanks
    > Chris
    >
    >

    Steve C. Orr, MCSD Guest

  4. #3

    Default Re: ASP.NET is "butchering" my code

    "Chris Mahoney" <chrismahoney@paradise.net.nz> wrote in
    news:uCzbSLCTDHA.3144@tk2msftngp13.phx.gbl:
    > <SNIP>
    > So my question is, why is ASP.NET removing all the formatting
    > code if the browser isn't IE, and most importantly, how do I
    > stop it from doing this?
    Chris,

    It's not realistic for ASP.NET to know and/or anticipate the
    capabilities of every existing browser, not to mention future ones.
    IMHO, I believe this (and not some nefarious conspiracy) is the
    reason that MS built ASP.NET to target IE, since IE is the dominant
    browser. For non-IE browsers, ASP.NET takes the least-common-
    denominator approach when generating HTML.

    One way around this is to use cascading style sheets (CSS). Let CSS
    do the work of positioning/formatting the HTML, rather than ASP.NET.
    It's more work, but in the end you'll have almost complete control
    over the way the HTML looks, and it will be much easier to get a
    uniform look across an entire site.

    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    [url]http://www.crtimmonsinc.com/[/url]
    Chris R. Timmons Guest

  5. #4

    Default Re: ASP.NET is "butchering" my code

    Thanks, it looks fine in both IE and Safari now. It also looks better, but
    not perfect, in Netscape.

    Chris


    "Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
    news:O$fSiXCTDHA.1324@TK2MSFTNGP11.phx.gbl...
    > Yes, ASP.NET tries to be smart and not send any HTML to a browser that
    it's
    > not sure that browser can handle.
    > There are ways to deal with these kinds of issues.
    > For instance, try some code like this to set your field width:
    >
    > MyTextBox.Attributes.Add("style", "width:350px;")
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD
    > [url]http://Steve.Orr.net[/url]
    >
    >
    >
    > "Chris Mahoney" <chrismahoney@paradise.net.nz> wrote in message
    > news:uCzbSLCTDHA.3144@tk2msftngp13.phx.gbl...
    > > Hi
    > >
    > > I have two machines, one running Win 2000 and VS.NET 2002, and one
    running
    > > Mac OS 10.2.
    > >
    > > I can develop web apps on my Windows machine, and look at them in IE,
    and
    > > they look fine. But if I try to view my pages in Safari (Apple's web
    > > browser) on my Mac, there are various formatting problems. I've
    > investigated
    > > what's happening and it seems that ASP.NET is discriminating against
    > Safari
    > > (and other browsers).
    > >
    > > For testing, I set up a simple ASP.NET page with a single TextBox on it,
    > > which I resized. It uses the following line of code:
    > >
    > > <asp:textbox Height="50" ID="TextBox1" runat="server"
    TextMode="MultiLine"
    > > Width="350" />
    > >
    > > Now, I can open the resulting page using IE, and if I look at the HTML
    > code
    > > generated by ASP.NET (by using View Source), the line responsible for
    > > drawing the TextBox is:
    > >
    > > <textarea name="TextBox1" id="TextBox1"
    > > style="height:50px;width:350px;"></textarea>
    > >
    > > That line contains all the code necessary to draw the TextBox to the
    size
    > I
    > > want, and displays fine in IE. However, opening the same page in Safari
    > and
    > > looking at the source, I see this code:
    > >
    > > <textarea name="TextBox1" id="TextBox1"></textarea>
    > >
    > > Huh? Where's all the sizing information gone? The TextBox sizes itself
    to
    > > whatever the default is, which is nowhere near as large as what I want
    it
    > to
    > > be. Well maybe Safari isn't capable of drawing the TextBox to the
    required
    > > size? But I've checked this out too, and that's not the problem. By
    > enabling
    > > the debugging functions in Safari, there's now an option for changing
    the
    > > user agent and pretending you're a different browser. So I set the user
    > > agent to IE6 on Windows, and voila, the TextBox now appears the correct
    > size
    > > in Safari. I looked at the various user agents available in Safari
    > (Mozilla
    > > 1.1, Netscape 7.0, Netscape 6.2.2, Netscape 4.79, Mac IE 5.22, Windows
    IE
    > > 6.0, and Konqueror 3), and all of those user agents, which the exception
    > of
    > > the IE ones, receive this "butchered" code.
    > >
    > > I proceeded to open up my "proper" site, which is loaded with controls
    and
    > > formatting problems, set Safari's user agent to IE6 for Windows, and the
    > > site appears almost perfectly! Most of the formatting problems I was
    > having
    > > have completely disappeared.
    > >
    > > So my question is, why is ASP.NET removing all the formatting code if
    the
    > > browser isn't IE, and most importantly, how do I stop it from doing
    this?
    > >
    > > Thanks
    > > Chris
    > >
    > >
    >
    >

    Chris Mahoney Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139