Reputation: 4811
I am getting an error because the razor and html is getting confused by the compiler I imagine.
<div id="@Model.MyLabelCars" ...>
My model variable is:
Model.MyLabel
The "Cars" is just raw text that should be in the HTML.
So say Model.MyLabel's value is "123" the ID should be:
id="123Car"
How can I seperate the model's variable name and HTML?
Upvotes: 2
Views: 5573
Reputation: 62260
You could use regular string add operator
<div id="@(Model.MyLabel + "Car")"></div>
Or C# 6's string interpolation.
<div id="@($"{Model.MyLabel}Car")"></div>
Upvotes: 10
Reputation: 93444
What you want is to use the <text></text>
pseudo tags
<div id="@Model.MyLabel<text>Cars</text>" ...>
Upvotes: 0