We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to disable checkbox in helper

Thread ID:





126135 Sep 26,2016 05:02 PM UTC Sep 27,2016 12:15 PM UTC ASP.NET MVC 1
Tags: Checkbox
Tom Frajer
Asked On September 26, 2016 05:02 PM UTC

I have my own CheckBoxFor implementation (I need strongy typed checkbox that you do not provide). My problem is, that Im not able to disable this checkbox. Here is the code of the helper. I highlighted part, where Im adding your class to make checkboxes look like syncfusion checkboxes. When I comment-out this highlighted line, checkbox is not styled properly, but disabling works. How can I achieve syncfusion styling and ability to control disable property of checkbox?

using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using CarDat.Service;

namespace CarDat.Helpers
    public static class CheckBoxExtensions

        public static MvcHtmlString LabeledCheckBoxFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, bool>> expression, string label)
            // Set class attribute for css styling
            var attributes = new RouteValueDictionary();
            attributes.Add("class", "check_box");

            // Get field name
            var body = expression.Body as MemberExpression;
            var fieldName = body.Member.Name;

            // Initialize new service for retrieving user rights
            var permissionService = new PermissionService();

            // Get field read permissions for current user role
            var canRead = permissionService.HasFieldReadPermission(fieldName);

            // Get field read permissions for current user role
            var canEdit = permissionService.HasFieldWritePermission(fieldName);

            // Render HTML code for label and input field
            var html = "";
            if (canRead || canEdit) {
                if (!canEdit) {
                    attributes.Add("disabled", "disabled");
                html = htmlHelper.Label(label).ToString();
                html += "<br />";
                html += InputExtensions.CheckBoxFor(htmlHelper, expression, attributes).ToString();

            return new MvcHtmlString(html);


Deepa Loganathan [Syncfusion]
Replied On September 27, 2016 12:15 PM UTC

Hi Tom,    
Sorry for the inconvenience caused. We are able to reproduce the reported issue on our end and logged a bug report to fix this. 
Also, we have created a new support incident under your account to track the status of this issue.  
Please log on to our support website to check for further updates. 
Please let us know if you have any further queries.   
Deepa Loganathan.   


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon