Model Binding

You can bind a Telerik UI RadioButton to a model.

  1. Make sure you followed all the steps from the introductory article on Telerik UI for ASP.NET Core.
  2. Create a new action method and pass the instance of the model to the View.

    public class RadioButtonModel
    {
        public bool IAgreeProp { get; set; }
    }
    
    public partial class ButtonController : Controller
    {
        public ActionResult RadioButton()
        {
            RadioButtonModel myModel = new RadioButtonModel() { IAgreeProp = false };
            return View(myModel);
        }
    }
    
  3. Make your view strongly typed.

    @model Kendo.Mvc.Examples.Controllers.RadioButtonModel
    
  4. Add two RadioButtons and set the Boolean values for the checked state through the .Value setting. The matched Boolean value from model will define the initial checked state.

    The following example demonstrates how the radio button with the I Disagree label will be checked because its false value matches the model value.

    @(Html.Kendo().RadioButtonFor(m => m.IAgreeProp).Label("I agree").Value(true))
    @(Html.Kendo().RadioButtonFor(m => m.IAgreeProp).Label("I Disagree").Value(false))
    

See Also

In this article
Not finding the help you need? Improve this article