前边我知道,括号里边的该怎么改
@Html.TextBox
@Html.ValidationMessage("Name", "*")
@Html.TextArea("Description", new { rows = "8", @class="textbox" })
            <p>
                <label for="Name">类别名称:</label>
                <%= Html.TextBox("Name",null,new{@class="textbox"}) %>
                <%= Html.ValidationMessage("Name", "*") %>
            </p>
            <p>
                <label for="Description">类别说明:</label>
                <%= Html.TextArea("Description", new { rows = "8", @class="textbox" })%>
            </p>

解决方案 »

  1.   


    前边一个是aspx的方式,是别人写的,我想改成纯的razor的方式
      

  2.   


    @model List<VideoCategories>
    @{
        ViewBag.Title = "NewAddCategory";
    }
    @using (Html.BeginForm())
    {
            <fieldset>
                <legend>视频类别</legend>
                <p>
                    <label for="Name">类别名称:</label>
                    @Html.TextBoxFor(Model => Model.Name, new { style = "width:80%", maxlength = "80" }) 
                    <%= Html.ValidationMessage("Name", "*") %>
                </p>
                <p>
                    <label for="Description">类别说明:</label>
                    @Html.TextAreaFor(a => a.Description, new { rows = "8" })
                </p>
                <p>
                上级类别:@Html.CategoryDropdown(model, "ParentId", null, null, "—无—")
                </p>
                <p>
                    <label for="Display">是否显示:</label>
                    <%= Html.CheckBox("Display",true) %>
                </p>
                <p>
                    <input type="submit" value="保存(S)" accesskey="S" />
                </p>
            </fieldset>
    }
    显示错误如下错误 1 “System.Collections.Generic.List<Webtest.WebVOD.Models.VideoCategories>”不包含“Name”的定义,并且找不到可接受类型为“System.Collections.Generic.List<Webtest.WebVOD.Models.VideoCategories>”的第一个参数的扩展方法“Name”(是否缺少 using 指令或程序集引用?) f:\code\BYVOD\Views\Admin\NewAddCategory.cshtml 50 49 BYVOD
    错误 2 “System.Collections.Generic.List<Webtest.WebVOD.Models.VideoCategories>”不包含“Description”的定义,并且找不到可接受类型为“System.Collections.Generic.List<Webtest.WebVOD.Models.VideoCategories>”的第一个参数的扩展方法“Description”(是否缺少 using 指令或程序集引用?) f:\code\BYVOD\Views\Admin\NewAddCategory.cshtml 55 42 BYVOD
    错误 3 当前上下文中不存在名称“model” f:\code\BYVOD\Views\Admin\NewAddCategory.cshtml 58 41 BYVOD
      

  3.   

    那当然,你绑定的模型是List<Webtest.WebVOD.Models.VideoCategories>
    你的View显然是对其中一条记录来的。如果你觉得必须这样,这么修改
    Model => Model.Name
    ->
    Model => Model[0].Name其余类似。