Balaji Kondalrayal
Balaji Kondalrayal

Reputation: 1751

How to display the text in MVC?

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.

Upvotes: 2

Views: 142

Answers (4)

Ramkumar
Ramkumar

Reputation: 106

Just try it,

ModelState.Clear();

Upvotes: 3

tfn_u
tfn_u

Reputation: 126

add this row top of view page.

@model YourNamespace.yourModel

and change this

@Html.EditorFor(model => model.CompileOutput)

Upvotes: 0

hutchonoid
hutchonoid

Reputation: 33306

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.

Upvotes: 0

why don't you try this to show textbox

@Html.TextBoxFor(up => up.CompileOutput)

Upvotes: 0

Related Questions