1

For example, I have this textbox

 <input id="@item.Id" type="number" value="@item.TotalAmount" />

and when rendered out, it becomes

<input id="1048" type="number" value="3.60" />

How do I add a letter to the id to make the rendered out textbox to become?

<input id="T1048" type="number" value="3.60" />

I tried below but it doesn't work

<input id="[email protected]" type="number" value="@item.TotalAmount" />
1
  • 1
    try with id='T@(item.id)' or you can also use String.Format("T{0}", @item.id) with Razor. Let me know if it works. Commented Jan 12, 2020 at 7:27

1 Answer 1

1

try like this it will resolve your issue

<input id="item_@(item.Id)" type="number" value="@item.TotalAmount" />

or you can also use String.Format in it like

<input id="@String.Format("item_{0}", item.Id)">
Sign up to request clarification or add additional context in comments.

Comments

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.