ASP with Mozilla

N

news.iq.ca

Hello,

I am learning ASP.net (for the moment, I'm still writing the code by hand,
in Notepad - VS.NET can wait for now).

The original text code is this:

--------------------------------------------------------------------------------------------------
<p>
<asp:label id="lbl1" text="Unbound, with ListItem." runat="Server"/>
<p>
<asp:listbox id="lstBox1" onselectedindexchanged="listbox_Changed"
width="200" backcolor="Red" rows="3" runat="server">
<asp:listitem text="Red" value="R"/>
<asp:listitem text="Green" value="G" Selected="true"/>
<asp:listitem text="Blue" value="B"/>
</asp:listbox>
--------------------------------------------------------------------------------------------------

Microsoft or not, the code, once compiled, translates into HTML like this:

MS Explorer:
--------------------------------------------------------------------------------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1"
style="background-color:Red;width:200px;">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
--------------------------------------------------------------------------------------------------

And this is the code rendered by Mozilla:
--------------------------------------------------------------------------------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
--------------------------------------------------------------------------------------------------

My question is - what happened to the "style" tag in Mozilla ? As a result,
the page does look VERY different than the page rendered by Explorer !

In my ASP book I read that ASP.net, regardless of the language (VB, C#...)
and the controls used, still sends the result in standard HTML, as much as
possible (meaning that if a feature exists in ASP.NET but not in HTML,
obviously, it won't be taken into consideration by the browser). Still, the
background-color is standard HTML, or the "width"- there's nothing fancy
about this code, like, for instance, usage of a Calendar Web Control, or an
Ad Rotator, or a RangeValidator. So either the book is wrong, either Mozilla
understands HTML only partially.

Thank you,
Alex
 
J

Jos

news.iq.ca said:
Hello,

I am learning ASP.net (for the moment, I'm still writing the code by
hand, in Notepad - VS.NET can wait for now).

The original text code is this:

-------------------------------------------------------------------------- ------------------------
<p>
<asp:label id="lbl1" text="Unbound, with ListItem." runat="Server"/>
<p>
<asp:listbox id="lstBox1" onselectedindexchanged="listbox_Changed"
width="200" backcolor="Red" rows="3" runat="server">
<asp:listitem text="Red" value="R"/>
<asp:listitem text="Green" value="G" Selected="true"/>
<asp:listitem text="Blue" value="B"/>
</asp:listbox>
-------------------------------------------------------------------------- ------------------------

Microsoft or not, the code, once compiled, translates into HTML like
this:

MS Explorer:
-------------------------------------------------------------------------- ------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1"
style="background-color:Red;width:200px;">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
-------------------------------------------------------------------------- ------------------------

And this is the code rendered by Mozilla:
-------------------------------------------------------------------------- ------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
-------------------------------------------------------------------------- ------------------------

My question is - what happened to the "style" tag in Mozilla ? As a
result,
the page does look VERY different than the page rendered by Explorer !

In my ASP book I read that ASP.net, regardless of the language (VB,
C#...)
and the controls used, still sends the result in standard HTML, as
much as
possible (meaning that if a feature exists in ASP.NET but not in HTML,
obviously, it won't be taken into consideration by the browser).
Still, the
background-color is standard HTML, or the "width"- there's nothing
fancy
about this code, like, for instance, usage of a Calendar Web Control,
or an
Ad Rotator, or a RangeValidator. So either the book is wrong, either
Mozilla understands HTML only partially.

Thank you,
Alex

I guess ASP.NET is wrongly assuming that Mozilla doesn't know the style
attribute.

You can work around it by adding the style attribute to the asp:Listbox tag
yourself.
When you do, you will be able to check for yourself that Mozilla understands
the HTML.
 
B

Benjamin Gavin

Yes,
The Microsoft provided browser detection strings are braindead as
they relate to any non-IE browser. You need to grab an updated
browserCaps definition to paste into your web.config [or machine.config
if you want]. The URL to grab an updated one is:

http://slingfive.com/pages/code/browserCaps/

Ben
 
N

news.iq.ca

Perfect ! Thank you - it worked like a charm. Now my pages looks the same in
both IE and Mozilla.

Thanks again,
Alex.

Benjamin Gavin said:
Yes,
The Microsoft provided browser detection strings are braindead as they
relate to any non-IE browser. You need to grab an updated browserCaps
definition to paste into your web.config [or machine.config if you want].
The URL to grab an updated one is:

http://slingfive.com/pages/code/browserCaps/

Ben

news.iq.ca said:
Hello,

I am learning ASP.net (for the moment, I'm still writing the code by
hand, in Notepad - VS.NET can wait for now).

The original text code is this:

--------------------------------------------------------------------------------------------------
<p>
<asp:label id="lbl1" text="Unbound, with ListItem." runat="Server"/>
<p>
<asp:listbox id="lstBox1" onselectedindexchanged="listbox_Changed"
width="200" backcolor="Red" rows="3" runat="server">
<asp:listitem text="Red" value="R"/>
<asp:listitem text="Green" value="G" Selected="true"/>
<asp:listitem text="Blue" value="B"/>
</asp:listbox>
--------------------------------------------------------------------------------------------------

Microsoft or not, the code, once compiled, translates into HTML like
this:

MS Explorer:
--------------------------------------------------------------------------------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1"
style="background-color:Red;width:200px;">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
--------------------------------------------------------------------------------------------------

And this is the code rendered by Mozilla:
--------------------------------------------------------------------------------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
--------------------------------------------------------------------------------------------------

My question is - what happened to the "style" tag in Mozilla ? As a
result, the page does look VERY different than the page rendered by
Explorer !

In my ASP book I read that ASP.net, regardless of the language (VB,
C#...) and the controls used, still sends the result in standard HTML, as
much as possible (meaning that if a feature exists in ASP.NET but not in
HTML, obviously, it won't be taken into consideration by the browser).
Still, the background-color is standard HTML, or the "width"- there's
nothing fancy about this code, like, for instance, usage of a Calendar
Web Control, or an Ad Rotator, or a RangeValidator. So either the book is
wrong, either Mozilla understands HTML only partially.

Thank you,
Alex
 
B

Burak

Hello,

I am creating an <asp:label> dynamically and setting its width in the
code behind as follows

Dim lbl3 As New Label
lbl3.Text = name
lbl3.Width = System.Web.UI.WebControls.Unit.Point(255)
pnlMain.Controls.Add(lbl3)

This gets rendered as

<span style="width:255pt;">

which shows up fine in IE but not in Netscape 7.1

I added the browsercaps definition into the web.config file as you
wrote but the width is still not getting set for the span in Netscape.

Do you have any other suggestions?

Thank you,

Burak

Benjamin Gavin said:
Yes,
The Microsoft provided browser detection strings are braindead as
they relate to any non-IE browser. You need to grab an updated
browserCaps definition to paste into your web.config [or machine.config
if you want]. The URL to grab an updated one is:

http://slingfive.com/pages/code/browserCaps/

Ben

news.iq.ca said:
Hello,

I am learning ASP.net (for the moment, I'm still writing the code by hand,
in Notepad - VS.NET can wait for now).

The original text code is this:

--------------------------------------------------------------------------------------------------
<p>
<asp:label id="lbl1" text="Unbound, with ListItem." runat="Server"/>
<p>
<asp:listbox id="lstBox1" onselectedindexchanged="listbox_Changed"
width="200" backcolor="Red" rows="3" runat="server">
<asp:listitem text="Red" value="R"/>
<asp:listitem text="Green" value="G" Selected="true"/>
<asp:listitem text="Blue" value="B"/>
</asp:listbox>
--------------------------------------------------------------------------------------------------

Microsoft or not, the code, once compiled, translates into HTML like this:

MS Explorer:
--------------------------------------------------------------------------------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1"
style="background-color:Red;width:200px;">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
--------------------------------------------------------------------------------------------------

And this is the code rendered by Mozilla:
--------------------------------------------------------------------------------------------------
<p>
<span id="lbl1">Unbound, with ListItem.</span>
<p>
<select name="lstBox1" size="3" id="lstBox1">
<option value="R">Red</option>
<option selected="selected" value="G">Green</option>
<option value="B">Blue</option>
--------------------------------------------------------------------------------------------------

My question is - what happened to the "style" tag in Mozilla ? As a result,
the page does look VERY different than the page rendered by Explorer !

In my ASP book I read that ASP.net, regardless of the language (VB, C#...)
and the controls used, still sends the result in standard HTML, as much as
possible (meaning that if a feature exists in ASP.NET but not in HTML,
obviously, it won't be taken into consideration by the browser). Still, the
background-color is standard HTML, or the "width"- there's nothing fancy
about this code, like, for instance, usage of a Calendar Web Control, or an
Ad Rotator, or a RangeValidator. So either the book is wrong, either Mozilla
understands HTML only partially.

Thank you,
Alex
 
J

Jens Ansorg

Burak said:
Hello,

I am creating an <asp:label> dynamically and setting its width in the
code behind as follows

Dim lbl3 As New Label
lbl3.Text = name
lbl3.Width = System.Web.UI.WebControls.Unit.Point(255)
pnlMain.Controls.Add(lbl3)

This gets rendered as

<span style="width:255pt;">

which shows up fine in IE but not in Netscape 7.1

I added the browsercaps definition into the web.config file as you
wrote but the width is still not getting set for the span in Netscape.

SPAN is an inline element as opposed to i.e. DIV,P which are block elements.

inline elements get placed in the text flow of a page comparable to a
single Letter/character and therefore cannot be defined to have a
certain width.

Mozilla rendering is as dpecified
MSIE is wrong.

If xou need something to be of y certain size it has to be a block level
element like a DIV.

You could try to override the render method of a control to get the
correct HTML code


..net is from Microsoft and it shows on every corner :(
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top