I have this code
@if (ViewBag.TechnologyNames != null)
{
foreach (var technologyName in ViewBag.TechnologyNames)
{
if (@technologyName.TechnologyID == -1)
{
<div class="CheckBoxItem">
<input type="checkbox" name="option1" id="allTechnology" value="@technologyName.TechnologyID" checked="checked" />
@technologyName.Name
</div>
}
else
{
<input type="checkbox" name="option2" id="tech" value="@technologyName.TechnologyID" />
@technologyName.Name
}
}
}
What I need is somehow to add @technologyName.TechnologyID
to id="tech"
to have at the end
id="tech_123"
How I can do it?
Thank you!
Yes!
The value attribute in HTML is used to specify the value of the element with which it is used. It has different meaning for different HTML elements. Usage: It can be used with the following elements: <input>, <button>, <meter>, <li>, <option>, <progress>, and <param>, <output>.
div elements don't have a . value property that would get submitted to the backend; use an input element for that.
try this (basically adding parenthesis around the property):
<input type="checkbox" name="option2" id="tech_
@(technologyName.TechnologyID)" value="@technologyName.TechnologyID" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With