user623863 user623863 - 2 months ago 9
ASP.NET (C#) Question

Textbox Width Problems - ASP.NET

I have a user control on a page of a website that generates a text box. The textbox has a width specified, but the text box is intermitently being shown at a much smaller width than is specified in the code. I asked the users to send me copies of the "view source" output so that I could compare good and bad results. By "intermittent", I mean similar builds - different computers. Please note that the bad results are ALWAYS displayed on the same "bad" computers (there is more than one user with this problem) and, conversely, the "good" computers (all with the same version of IE7 as the "bad" computers) always display "good" results.

When the page is displayed correctly, the html that is sent to the browser looks like this:

<input name="ShortDescription" type="text" maxlength="100"
id="ShortDescription" class="content" style="width:800px;" />


and when it renders incorrectly, it looks like this:

<input name="ShortDescription" type="text" maxlength="100"
id="ShortDescription" class="content" />


In both cases, the ASP.NET code is:

<asp:textbox id="ShortDescription" runat="server"
CssClass="content" Width="800px" MaxLength="100"> </asp:textbox>


I am not sure why the style tag is getting dropped. The above pages were both viewed in the same browser (IE7) on different computers. The computers have a corporate build so they "should" be configured the same.

I would appreciate any help!

Answer

Try setting the TextBox with in the CssClass, or as a style attribute parameter rather than using the Width attribute

<asp:TextBox id="ShortDescription" runat="server" CssClass="content" MaxLength="100" style="width: 800px" />
<style>.content { width: 800px }</style>
<asp:TextBox id="ShortDescription" runat="server" CssClass="content" MaxLength="100" />
Comments