Patito00Game
Patito00Game

Reputation: 1

How can I join a c# code with a html text

I'm trying to do this:

<h1> Pagina [email protected]</h1>

But, when I start the page the text is this:

Pagina [email protected]

How can I join the variable Model.Restaurant.Id with a text? Like this:

Model.Restaurant.Id = 5

Pagina n5

Thanks for your help!

Upvotes: 0

Views: 55

Answers (2)

Shawn Xiao
Shawn Xiao

Reputation: 590

Try this: <h1> Pagina n<%= Model.Restaurant.Id %></h1> or <h1> Pagina n<%: Model.Restaurant.Id %></h1> or <h1> Pagina n@(Model.Restaurant.Id) %></h1>

Upvotes: 0

Stack Undefined
Stack Undefined

Reputation: 1340

You can use string interpolation.

<h1>@($"Pagina n{Model.Restaurant.Id}")</h1>

Upvotes: 2

Related Questions