views:

45

answers:

4

Here is the ASP.Net MVC2 code that I use to display a textbox input.

<div id="blackbar">
    <p>Sistema de Evaluaciones de Docentes</p>
    <%: Html.TextBox("termino","") %>
    <img src="../../Content/search.png" alt="search" />
</div>

Here is how it renders:

<div id="blackbar">
    <p>Sistema de Evaluaciones de Docentes</p>
    <input id="termino" name="termino" type="text" value="" />
    <img src="../../Content/search.png" alt="search" />
</div>

How would I use CSS for example to give the textbox a red border? How can I tell MVC2 to give this text input a class or something?

EDIT: I've tried the following, but the text I write into the input isn't green.

.textinput
{
    color:Green;
}

<%: Html.TextBox("termino", "", new { @class = "textinput" })%>
A: 
#termino { border: solid 1px #F00; } 
C Bauer
A: 
input[name=termino],
input#termino,
#termino
{
border: 1px solid #f00;
}
David Thomas
+6  A: 
<%=Html.TextBox("termino", "", new { @class = "redborder" }) %>
hunter
+1 for answering the second part of the question (I have no experience of ASP/MVC2, so could only answer how to style after it's generated).
David Thomas
Hi, please see edit.
Sergio Tapia
Nevermind, I was loading the CSS file from cache. MASSIVE thanks for your help.
Sergio Tapia
no problem! you were 1/2 way there
hunter
A: 

To style all text boxes in the blackbar div you can use:

#blackbar input[type='text'] { ... }
Philip Smith