1

I am trying to figure out whether it is possible to achieve it.

I was previously writing something like this:

or

<div id="[email protected]"/>

and it worked.

However, the need arose to change the way of setting ids, as it does not meet the requirements anymore.

I would like to concat two values, something like this:

<div id="@i.category + @i.category2" />

however the above does not work. I also tried:

<div id ="@(i.category + i.category2)" />

but it did not work neither.

Can anyone suggest a solution?

1
  • <div id='@$"{i.category}{i.category2}"' /> Commented Oct 4, 2019 at 20:15

1 Answer 1

2

You can use string.Format for this:

<div id="@string.Format("{0}{1}", i.category, i.category2)" />
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot!. this seems to be responding to my needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.