C# MVC无法从代码到html页面获取值

C# MVC无法从代码到html页面获取值,c#,asp.net-mvc,html-helper,C#,Asp.net Mvc,Html Helper,我试图从C#到MVC文本框中获取值。但它不是以HTML显示的 我使用了以下代码: foreach (CompilerError CompErr in results.Errors) { userProgram.CompileOutput = "Line number " + CompErr.Line + ", Error Number: " + CompErr.ErrorNumbe

我试图从C#到MVC文本框中获取值。但它不是以HTML显示的

我使用了以下代码:

foreach (CompilerError CompErr in results.Errors)
            {

                userProgram.CompileOutput = "Line number " + CompErr.Line +
                             ", Error Number: " + CompErr.ErrorNumber +
                             ", '" + CompErr.ErrorText + ";" +
                             Environment.NewLine + Environment.NewLine;
                output = userProgram.CompileOutput;
            }

var model = new UserProgram()
        {
            CompileOutput = output
        };
        return View(model);
以下代码采用cshtml格式:

@Html.EditorFor(up => up.CompileOutput, new{style = "width:100px; height:50px; "})

若您将模型发布到控制器,然后在控制器中更改模型,在视图中它将显示您首先发布的内容,发布的数据具有更高的优先级。您可以尝试清除modelstate

ModelState.Clear();

显示代码以在中显示它view@x2. - 我已经编辑了我的问题。请看那个..在HTML页面中,它没有显示与我们作为输入提供的内容相同的内容。UserProgram类中的CompileOutput类型是什么?@AbhinavRajan-virtual StringU非常感谢x2。我们已经工作了大约14个小时。非常感谢你+1给你。。。。