For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > December 2005 > Textbox Width Issue (Rendered differently for different browsers)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Textbox Width Issue (Rendered differently for different browsers)
Jeff

2005-12-17, 7:57 am

Using ASP.NET 1.1

I have an <asp:TextBox... for which I set the width property --- "width=30".

The textbox is being rendered to the browser like this:

<input name="someName" type="text" maxlength="3" id="someID"
style="width:30px;" />

Notice the [Width=30] gets rendered as [style="width:30px;"]. This causes
the textbox to be 30 pixels wide, at least in IE and Opera.

I have discovered in testing that the [style="width:30px;"] part is *omitted
completely* from the rendered HTML when the page is requested by FireFox or
Netscape Navigator (6.2) - so the textbox (really <input... /> ) gets some
default width rather than being set to 30 pixels wide.

What can I do to set the width the same for FireFox and NN (same as for IE)?

Thanks!


Showjumper

2005-12-17, 7:57 am


Dont use inline styles. Rather use the cssclass property and set it to a
class defined in your stylesheet. The problem w/ the inline styles is that
asp.net see gecko browser as downlevel and as such doesnt send the inline
style info. And i would have thought that it woulndt send it to Opera either
since it considers only ie as uplevel.
"Jeff" <Jeff@NoSpam.com> wrote in message
news:OXdpRXvAGHA.2040@TK2MSFTNGP14.phx.gbl...
>
> Using ASP.NET 1.1
>
> I have an <asp:TextBox... for which I set the width property ---
> "width=30".
>
> The textbox is being rendered to the browser like this:
>
> <input name="someName" type="text" maxlength="3" id="someID"
> style="width:30px;" />
>
> Notice the [Width=30] gets rendered as [style="width:30px;"]. This causes
> the textbox to be 30 pixels wide, at least in IE and Opera.
>
> I have discovered in testing that the [style="width:30px;"] part is
> *omitted completely* from the rendered HTML when the page is requested by
> FireFox or Netscape Navigator (6.2) - so the textbox (really <input... /> )
> gets some default width rather than being set to 30 pixels wide.
>
> What can I do to set the width the same for FireFox and NN (same as for
> IE)?
>
> Thanks!
>
>




Eirik

2005-12-17, 7:02 pm

Take a look at the following URL for an Browsercap update too add to your
web.config or machine.config file.
http://slingfive.com/pages/code/browserCaps/

That should take care of that problem with asp.net considering most browsers
as downlevel.

Regards


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com