Difference in formatting content in TextArea and Notepad

5

I have an ASP.NET MVC application where I display in a text area a content that is in the database.

@Html.TextArea("Avisos", Model.Avisos, new { @class = "form-control", rows = 50, style = "max-width:none", @readonly = "" })

The display is misaligned like this:

ButifIcopythecontentsofthetextarea,andpasteitintoNotepad,itisok,asexpected:

I have no idea why the difference and how to solve.

    
asked by anonymous 01.06.2016 / 20:58

1 answer

4

Because of the font used within <textarea> . Possibly the style sheet is not using a monospaced font.

Try setting a style like this:

textarea {
  font-family: Consolas, Lucida Console, Courier New, Courier;
}

In your case, you can define inline , like this:

@Html.TextArea("Avisos", Model.Avisos, new { @class = "form-control", rows = 50, style = "max-width: none; font-family: Consolas, Lucida Console, Courier New, Courier", @readonly = "" })

I made a Fiddle .

    
01.06.2016 / 21:16