Hi,
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);
}
}
}