Home Make a Checkbox none clickable ASP.NET MVC5
Reply: 0

Make a Checkbox none clickable ASP.NET MVC5

user9269 Published in September 19, 2018, 11:05 am

I have a table which renders some data from the Model and Controller. I have the table working, however, is there a way that I can stop the checkboxes in the table being clicked.

My code is:

                @for(var i = 0; i < Model.Writers.Count(); i++)
                <tr data-id="@Model.Writers[i].WriterId"

                    <td>@Model.Writers[i].FirstName @Model.Writers[i].LastName</td>
                    <td class="hidden-xs hidden-sm">@Model.Writers[i].Membership</td>
                    <td class="hidden-xs">@Model.Writers[i].CaeIpiNumber</td>
                    <td class="hidden-xs hidden-sm text-center">
                    @Html.CheckBoxFor(m => m.Writers[i].RightToCollect, new { @class = "control-label" })

I am just a little unsure whether it is possible to make the checkboxes no clickable, so they are locked in a way.

share|improve this question
  • Why do you manually set the checked attribute value? The checkbox state is defined by result of expression, that you passed as first argument of the helper method – Alexander Apr 11 at 13:03
  • @Alexander It is some fake data that I have in my controller to see whether its pulling the data from the model. I have removed all of that and gone back to the basics and it renders the checkbox input. Is there a way that I can lock it? – Rob Apr 11 at 15:09
  • Do you mean disabled attribute? – Alexander Apr 11 at 15:15
  • Or do you want to checkbox will be checked by default? – Alexander Apr 11 at 15:18
  • @Alexander the disabled option is okay, but I would like it so that you cant click the checkboxes. So they are locked. – Rob Apr 12 at 7:28

1 Answer 1

active oldest votes
up vote 1 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.697781 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO