I work on asp.net MVC 5 .NET Framework . I face issue I can't get value of Property SpeakStuff when catch Detail Action Result .
on object ResignationRequester property SpeakStuff represent by two check boxes Yes and No .
if SpeakStuff equal True then Yes checkbox will be checked
if SpeakStuff equal False then No checkbox will be checked
so How to do that when catch Detail Action Result
my code as below :
<div>
@Html.Label("Did You Meet/Speak to Staff", htmlAttributes: new { @class = "control-label col-md-5" })
<div class="col-md-7">
<input type="checkbox" id="SpeakStuff" name="SpeakStuff" value="true" class="speak-stuff-checkbox" @(Model.SpeakStuff ? "checked" : "") />
Yes
<input type="checkbox" id="SpeakStuff" name="SpeakStuff" value="false" class="speak-stuff-checkbox" @(!Model.SpeakStuff ? "checked" : "") />
No
</div>
</div>
$('.speak-stuff-checkbox').on('change', function () {
$('.speak-stuff-checkbox').not(this).prop('checked', false);
var selectedValue = $(this).val();
$('#SpeakStuff').val(selectedValue);
});
public class ResignationRequester
{
public bool SpeakStuff { get; set; }
}
[HttpGet]
public async Task<ActionResult> Details(int? id, string msg)
{
ResignationRequester workforceRequest = Workforce.ResignationGetRequestByID((int)id);
//when check workforceRequest.SpeakStuff it will be true or false
// so How to make check box yes checked when true and checkbox No checked when it False
return View(workforceRequest);
}
so suppose workforceRequest.SpeakStuff=false then No will checked as Image below :
