Changing a TextBox for Multiline while maintaining CSS

1

I have a web application with several TextBoxes. However, I need some of them to stick with Multiline because of the text they will contain. Every time I make this change I lose the CSS settings. From what I've researched it seems to me that the TextBox transforms into TextArea in Runtime.

So, I needed to know how to keep or even add CSS to this object, so I can keep my back colors, fonts, and Sizes.

Sample ASP:

  <asp:TextBox ID="txtCC"  runat="server" TextMode = "MultiLine"  Width="100%" CssClass="textArea" ReadOnly="True"></asp:TextBox><br />

CSS example

 .textArea 
{ 
    background-color:#EEEEEE;
    font-family: Verdana;
    font-size: 11px;
} 
    
asked by anonymous 01.07.2014 / 13:23

1 answer

2

Creating a simple application, with the data informed in the question, you can see that CSS is applied even using 'TextMode="MultiLine". So the page is probably not finding the CSS file. See the following example, which shows the Default.aspx page.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .textArea
        {
            background-color: green;
            font-family: Verdana;
            font-size: 21px;
        }
    </style>
</head>
<body style="height: 3000px">
    <form id="form1" runat="server">
    <asp:TextBox ID="txtCC" runat="server" TextMode="MultiLine" Width="100%" CssClass="textArea"
        ReadOnly="True"></asp:TextBox><br />
    </form>
</body>
</html>

See that I put a green background color to make it clear that the CSS application works. I also changed the font size to again evidence the style change.

    
13.07.2014 / 05:31