问题
I want to display the error message in a textbox in MVC. I used following code for that but its not displaying.
userProgram.CompileOutput = "Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine;
@Html.EditorFor(up => up.CompileOutput)
return View(userProgram);
In the above code userProgram returns the value for CompileOutput. But its not displaying in the textbox.
回答1:
Just try it,
ModelState.Clear();
回答2:
why don't you try this to show textbox
@Html.TextBoxFor(up => up.CompileOutput)
回答3:
If CompileOutput
is a string you could use the following:
@Html.TextBoxFor(up => up.CompileOutput)
If it is a complex object you need to define the EditorTemplate for that type.
回答4:
add this row top of view page.
@model YourNamespace.yourModel
and change this
@Html.EditorFor(model => model.CompileOutput)
来源:https://stackoverflow.com/questions/22298640/how-to-display-the-text-in-mvc