How to make the tag br / be recognized in html when it is returned from a database?

0

I am working in C # with MVC and I am saving text in SQL server but I need to do line breaks so I chose to include the <br/> tag to perform the jumps, from a view I made the insertion in the data base and another view I show that data, the problem is that I get the text with everything and the label as if it were part of the text, then I would like to know if someone knows how to solve this problem I have or some way to save line breaks in SQL server and I will recognize them when I show them in the view.

<p class="text-muted">@(Model.textopresentacion)</p>

In this tag I want to show the text with line breaks

    
asked by NecroAny 25.11.2017 в 02:10
source

2 answers

2

Use @Html.Raw where you convert a string and IHtmlString and allow you to print valid Html tags:

<p class="text-muted">@Html.Raw(Model.textopresentacion)</p>
    
answered by 25.11.2017 / 02:22
source
-1

You can get the container where you want to add it using JQuery and add it using .html ()

textoPresentacion = 'Probando <br/> Texto'

$('#test').html(textoPresentacion);

<p id='test'></p>

I got the container for its id and using .html () I added what I wanted and the next result was obtained.

<p id='test'>Probando <br/> Texto <p>
    
answered by 25.11.2017 в 04:37