Problems using TextBoxFor with viewModels in MVC

I recently started using viewModel. Here is the viewModel that I am using:

public class ContentViewModel
    {
        public Content Content { get; set; }
        public bool UseRowKey { 
            get {
                return Content.PartitionKey.Substring(2, 2) == "05" ||
                   Content.PartitionKey.Substring(2, 2) == "06";
            }
        }
        public string TempRowKey { get; set; }

    }

I changed the look of the razor:

@model WebUx.Content

<div class="colx2-left">
    <label for="complex-fr-url" class="required">Order</label>
    @Html.TextBoxFor(model => model.Order)
</div>

at

@model WebUx.Areas.Admin.ViewModels.Contents.ContentViewModel

<div class="colx2-left">
    <label for="complex-fr-url" class="required">Order</label>
    @Html.TextBoxFor(model => model.Content.Order)
</div>

Now my views fail with the following message:

Compiler Error Message: CS0411: Type Arguments for the System.Web.Mvc.Html.InputExtensions.TextBoxFor TModel, TProperty> Method (System.Web.Mvc.HtmlHelper <TModel>, System.Linq.Expressions.Expression <System.Func < TModel, TProperty>); cannot be taken out of use. Try explicitly specifying type arguments.

Can someone give me advice on what I should do?

+5
source share
2 answers

, , / , , .

.

, :

@model WebUx.Areas.Admin.ViewModels.Contents.ContentViewModel
@Html.EditorFor(model => model.Content)

:

@model WebUx.Content
<div class="colx2-left">
    <label for="complex-fr-url" class="required">Order</label>
    @Html.TextBoxFor(model => model.Order)
</div>

, Order. , .

+2

, Order Content. POC. , ? ViewModel.

:

public class UserViewModel
{
    [StringLength(16)]
    string Name { get; set; }

    [Range(18, 65)]
    int Age { get; set; }
}

.

, :

public class UserViewModel
{
    [StringLength(16)]
    public string Name { get; set; }

    [Range(18, 65)]
    public int Age { get; set; }
}
+1