1

In the default newly created MVC3 application, at the CRUD's Create view, the text box is implemented/called up as

    <div class="editor-field">
        @Html.EditorFor(model => model.EnrollmentDate)
        @Html.ValidationMessageFor(model => model.EnrollmentDate)             
    </div>

And the resulted html view file for that block becomes

<div class="editor-field">
            <input class="text-box single-line" data-val="true" data-val-required="The EnrollmentDate field is required." id="EnrollmentDate" name="EnrollmentDate" type="text" value="" />
            <span class="field-validation-valid" data-valmsg-for="EnrollmentDate" data-valmsg-replace="true"></span>             
        </div>

I look up the class single-line in the Site.css but I can't find it anywhere, only multi-line there is [:-D silly inversion].

Could someone tell me where it is ? is it a css keyword ?

Second, I don't know the difference between using EditFor member function from Html class and TextBox function also from Html especially when I would like to add new style elements to the textbox.

[EDIT] http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application

I am reading that tutorial

Sesama Sesame
  • 279
  • 3
  • 6
  • 19
  • See here for overriding the EditorFor functionality http://stackoverflow.com/questions/1625327/editorfor-and-html-properties – Rich Mar 17 '12 at 14:55

3 Answers3

0

Also you can use @Html.TextBoxFor(model=>model.Name, new {@class="class-name"}) instead of @Html.EditorFor()

0

Yes its a CSS style but it is not defined in the Site.css, the CSS that is applied in that instance is text-box and input[type="text"].

.text-box {
width: 30em;

}

input[type="text"], 
input[type="password"] {
border: 1px solid #ccc;
padding: 2px;
font-size: 1.2em;
color: #444;
width: 200px;

}

Lloyd
  • 2,932
  • 2
  • 22
  • 18
0

It's an emitted class attribute from a built-in editor template. This article explains them quite well.

http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-3-default-templates.html

Chris Gessler
  • 22,727
  • 7
  • 57
  • 83