Checkbox not working

5 posts, 1 answers
  1. David
    David avatar
    18 posts
    Member since:
    Jun 2015

    Posted 22 Jul 2015 Link to this post

    Hi, I am using Kendo for ASP.Net MVC version 2015.2.264 using the Blue Opal theme.  I have a checkbox input which is not "checkable" when bound to a model property via the @CheckBoxFor razor syntax.  It renders correctly using the Kendo assigned theme, but does not allow you to check it even though it is not disabled.

     

    This works:

         <div style="display:block;">
            <input type="checkbox" id="chkIntegrated" class="k-checkbox" name="Integrated">
            <label class="k-checkbox-label" for="chkIntegrated">Integrated 2</label> 
        </div>

     

     This does NOT work:

         <div style="display:block;">
            @Html.CheckBoxFor(Function(m) m.Integrated, New With {.class = "k-checkbox", .Id = "chkIntegrated"})
            @Html.LabelFor(Function(m) m.Integrated, New With {.class = "k-checkbox-label"})
        </div>

     

    I have attached the test html page which illustrates this.  Any ideas? 

     

     

          

  2. eo
    eo avatar
    27 posts
    Member since:
    Jul 2015

    Posted 22 Jul 2015 in reply to David Link to this post

    Hello David,

    Could you attach the model you're using as well as any other file used in the example?

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. David
    David avatar
    18 posts
    Member since:
    Jun 2015

    Posted 22 Jul 2015 Link to this post

    Hi eo - test project added ...
  5. Answer
    Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 24 Jul 2015 Link to this post

    Hello David,

    I'm afraid that the k-checkbox-label class is not designed to work with Html.CheckBoxFor. This is due to the fact that Html.CheckBoxFor will render two input elements but the k-checkbox-label requires the associated input element to be immediately before the label. Thus, you should either skip the use of Html.CheckBoxFor and create the checkbox HTML manually or consider using UI for ASP.NET MVC CheckBox which should work correctly.

    Regards,
    Rosen
    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
  6. David
    David avatar
    18 posts
    Member since:
    Jun 2015

    Posted 24 Jul 2015 Link to this post

    OK, thanks Rosen.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready