Is it possible to define an HTML tag in a C#string?

Asked

Viewed 288 times

0

I have the following string written in C#:

string Descricao = "Você ficou muito tempo inativo, e por isso sua sessão caiu. Retorne para a página inicial para continuar."

I would like to put the excerpt sessão caiu of the string within an HTML tag, more or less like this:

Descricao = "Você ficou muito tempo inativo, e por isso sua <span style="font-weight: bold">sessão caiu</span>. Retorne para a página inicial para continuar."

Is it possible? I’m trying according to the code above, but I’m getting it:

inserir a descrição da imagem aqui

  • 1

    It certainly is. You yourself did this in the question example.

  • @LINQ is not working when I show the string. It is as shown in the image.

  • @Ricardoalves This is the kind of thing that should be in the question, it is not easy to deduce this. Anyway, another important thing that you do not have in your question: what code you use to display this string?

  • @LINQ, this string is a property of a class called MensagemErro. An object of MensagemErro is passed to the view using Viewbag, and then I show it like this: @mensagemErro.Descricao

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.