Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 652
user623863 Avatar asked Feb 18 '11 22:02

user623863


3 Answers

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 }&lt/style>
<asp:TextBox id="ShortDescription" runat="server" CssClass="content" MaxLength="100" />
like image 161
KBoek Avatar answered Nov 03 '22 11:11

KBoek


Apply the min-width property.

In Your CSS Style Sheet

.Textbox
{
min-width:100%;
}

In Your *.aspx

<asp:TextBox  CssClass="TextboxStyle"  placeholder="Enter the Title" runat="server" ID="TextBox1"></asp:TextBox>

This will update your text box

like image 6
Parthiban Kannan Avatar answered Nov 03 '22 11:11

Parthiban Kannan


In the past I've found that setting the width through your class itself, instead of using the width property of the textbox will make sure the control is rendered properly.

like image 5
Dillie-O Avatar answered Nov 03 '22 12:11

Dillie-O