I have a list of checkboxes and I need to tell which are checked using C#
. How would I tell which individual checkboxes are checked and then add their values together? I am using Asp.Net Core
, if that could be helpful
<div class="row">
<form method="post" class="offset-3 col-5 border">
<div id="Colors" class="form-group" type="checkbox">
<label class="form-check-label">Colors</label>
<div class="form-check">
<input id="Red" class="form-check-input" type="checkbox" value="1">
<label class="form-check-label">Red</label>
</div>
<div class="form-check">
<input id="Yellow" class="form-check-input" type="checkbox" value="2">
<label class="form-check-label">Yellow</label>
</div>
<div class="form-check">
<input id="Green" class="form-check-input" type="checkbox" value="4">
<label class="form-check-label">Green</label>
</div>
<div class="form-check">
<input id="Blue" class="form-check-input" type="checkbox" value="8">
<label class="form-check-label">Blue</label>
</div>
<div class="form-group">
<input type="submit" value="Post" class="btn btn-primary" />
</div>
</div>
</form>
</div>