Text with line break

3

I pass some product info to an external billing service (site). On the screen of this site, the past information is in the "description" field, inside a h3 element, which appears to have 25 spaces with flexible height.

I go like this:

var descricao = "Codigo: " + codigoProduto + Environment.NewLine + "Nome: " + 
nome + Environment.NewLine;

try
        {
            paymentRequest.Items.Add(
             new Item(
                "BASIC " + CodID,
                 descricao,
                 1,
                 valor
             )
         );

On the screen everything appears together on the same line as this description field.

However, what you want is to have an info on each line, such as:

Código: 1234
Nome: Daniel

That way it works but the br appears on the screen.

descricao = $"Codigo: {CodID} <br/> Nome: {nome}";

Source code of the page that receives the data:

      <td>
        <h3 title="Codigo: 1983 br / Nome: Daniel">Codigo: 1983 br 
         / Nome: Daniel</h3>
            Quantidade: 1<br />
            Valor do item: R$ 6,00
        </td>
    
asked by anonymous 29.06.2018 / 14:43

2 answers

3

Another solution:

string retorno = $"<h3>Codigo: {codigoProduto} <br> Nome: {nome} <br> Valor:  {valor} </h3>";
    
29.06.2018 / 15:04
1

You can do this:

var NewLineHTML = "<br>" + Environment.NewLine;

var res = $"Codigo: {codigoProduto}" + NewLineHTML +
          $"Nome: {nome}" + NewLineHTML +
          $"Valor: {valor}" ;

This would look like this in the html, inside the pre-existing h3 tag:

<h3>
Codigo: 789<br>
Nome: CHURRASCO<br>
Valor: 12,34
</h3>

Rendering:

Patch:FromwhatIsawthesystemistaking<and>andsoitappearsbr...
Maybeyoucantryhackingthisbydoingthis:

changeto:

varNewLineHTML="_br_" + Environment.NewLine;

and on the page add this script

<script>
    document.body.innerHTML = document.body.innerHTML.replace(/_br_/g, '<br>');
</script>
    
29.06.2018 / 14:51