|
<ejs-radiobutton id="Yess" label="Yes" value="4" name="Diarrhea" checked="false"></ejs-radiobutton>
<br />
<br />
<ejs-radiobutton id="Noo" label="No" value="5" name="Diarrhea" checked="false"></ejs-radiobutton>
<br />
<br />
<button id="getValue" class="e-btn">Get Selected Value</button>
<script>
document.getElementById("getValue").addEventListener("click", () => {
var radiobuttonObj = ej.base.getComponent(document.getElementById("Yess"), "radio");
var selectedValue = radiobuttonObj.getSelectedValue();
// post the value here to pass it to the controller to save it to the database
})
</script> |
|
@model WebApplication1.Controllers.RadioButtonModel
<h6>Using Model</h6>
<ejs-radiobutton id="Yess" label="Yes" value="4" ejs-for="Diarrhea"></ejs-radiobutton>
<br />
<br />
<ejs-radiobutton id="Noo" label="No" value="5" ejs-for="Diarrhea"></ejs-radiobutton>
<br />
<h6>Without Using Model</h6>
<ejs-radiobutton id="Yess2" label="Yes" value="4" name="Diarrhea2"></ejs-radiobutton>
<br />
<br />
<ejs-radiobutton id="Noo2" label="No" value="5" name="Diarrhea2"></ejs-radiobutton> |
|
[HttpPost]
public IActionResult Index(RadioButtonModel model, string Diarrhea2)
{
return View();
}
public class RadioButtonModel
{ // Add this along with your model
public string Diarrhea { get; set; }
} |