I'm trying to build up a bit of HTML using a mix of razor variables and static content.
Here is where I get stuck: I have a counter variable in my view called section_counter
. I want to use that in the ID of the image tag I'm building. However unlike with <% .. %>
notation I'm used to, I'm just not able to do what I need.
<img alt="section" id="@section_counter_Section" src=""..... etc
I need the id to look like 3_Section
. However if I leave a space between the variable and the word _Section
, the value retains that space (3 _Section
).
If I use the <text>
hint, I get this:
<img alt="section" id="3<text>_Section</text>" src="
In my generated HTML. What am I missing?
Try putting your variable in brackets. (An explicit code nugget)