Jquery 文本区域中不显示数据

Jquery 文本区域中不显示数据,jquery,html,css,asp.net-mvc-4,textarea,Jquery,Html,Css,Asp.net Mvc 4,Textarea,我通过以下代码在mvc中绑定数据: @model DocumentManagementSystem.Models.DocumentFileName @{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } @using (Html.BeginForm("Upload", "Upload", FormMethod.Post, new { enctype = "multipart/form-dat

我通过以下代码在mvc中绑定数据:

@model DocumentManagementSystem.Models.DocumentFileName
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using (Html.BeginForm("Upload", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <table style="margin-top:50px;">
        <tr>
            <td>
                <input type="file" name="file" />
            </td>
            <td>
                <input type="submit" name="Submit" id="Submit" value="Upload" />
            </td>
        </tr>
    </table>
    @Html.TextAreaFor(f => f.Data, new { ViewBag.DocumentData })
}

据我所知,textareafor不能真正做到这一点,因为它绑定到
Model.Data
的值

在使用TextArea for之前,您不能将您的
模型.Data
声明为=
ViewBag.DocumentData

编辑:例如:

@model DocumentManagementSystem.Models.DocumentFileName
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    Model.Data = ViewBag.DocumentData;
}

@using (Html.BeginForm("Upload", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ 

    @Html.TextAreaFor(f => f.Data)
}

据我所知,textareafor不能真正做到这一点,因为它绑定到
Model.Data
的值

在使用TextArea for之前,您不能将您的
模型.Data
声明为=
ViewBag.DocumentData

编辑:例如:

@model DocumentManagementSystem.Models.DocumentFileName
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    Model.Data = ViewBag.DocumentData;
}

@using (Html.BeginForm("Upload", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ 

    @Html.TextAreaFor(f => f.Data)
}

我不明白你的意思,请解释一下。你已经在你的razor文件顶部定义了一个模型<代码>DocumentManagementSystem.Models.DocumentFileName。TextAreaFor绑定到该模型的“数据”属性。如果在使用TextArea for之前设置了
Model.Data=ViewBag.DocumentData
,然后,生成的文本区域将具有您设置的值。DocumentData将设置为。我在哪里设置'Model.Data=ViewBag.DocumentData'i am face'对象引用未设置为对象的实例。'错误现在请发布显示此视图的控制器操作代码。因此,我可以查看您是否正确创建并向其传递模型。我没有理解您,请解释一下。您已在razor文件的顶部定义了一个模型<代码>DocumentManagementSystem.Models.DocumentFileName。TextAreaFor绑定到该模型的“数据”属性。如果在使用TextArea for之前设置了
Model.Data=ViewBag.DocumentData
,然后,生成的文本区域将具有您设置的值。DocumentData将设置为。我在哪里设置'Model.Data=ViewBag.DocumentData'i am face'对象引用未设置为对象的实例。'错误现在请发布显示此视图的控制器操作代码。因此,我可以查看您是否正确地创建和传递模型。