kendo radio button

2 posts, 0 answers
  1. sanjay
    sanjay avatar
    3 posts
    Member since:
    Nov 2014

    Posted 13 Sep 2015 Link to this post

    I've following code in razor view. How do I use Kendo Radio button to render the same? I'm struggling to assign enum to radio button value.

    @if (Model == declaredEnum.​Val1) //declaredEnum is Enum
    {
        @Html.RadioButtonFor(l => l, (int)declaredEnum.​Val1, new { @checked = "checked" });
        
    }
    else
    {
        @Html.RadioButtonFor(l => l, (int)declaredEnum.​Val1);   
    }
    @Html.LabelFor(l => l, "Label")​

  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 16 Sep 2015 Link to this post

    Hello,

    I am not sure why is the condition needed but the equivalent code to the one that you are currently using would be:
    @if (Model == declaredEnum.Val1) //declaredEnum is Enum
    {   
        @Html.Kendo().RadioButtonFor(l => l).Value((int)declaredEnum.Val1).Checked(true);
         
    }
    else
    {
        @Html.Kendo().RadioButtonFor(l => l).Value((int)declaredEnum.Val1)
    }

    If the problem is with setting the enumeration value and not its corresponding integer value then please update to the latest service pack. There was an issue with outputting enumeration values that was already fixed.

    Regards,
    Daniel
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top