1

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" })%>
1
  • You could style this input by targeting the ID? eg. #termino {} in your CSS. Or are you wanting to apply/remove this style from a few elements? Commented Jul 30, 2010 at 15:05

4 Answers 4

6
<%=Html.TextBox("termino", "", new { @class = "redborder" }) %>
Sign up to request clarification or add additional context in comments.

2 Comments

+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).
Nevermind, I was loading the CSS file from cache. MASSIVE thanks for your help.
0
#termino { border: solid 1px #F00; } 

Comments

0
input[name=termino],
input#termino,
#termino
{
border: 1px solid #f00;
}

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.