vendredi 17 novembre 2017

why checkbox is hidden even using my htmlhelper?

I've read a lot of links about hidden filed bout checkbox I've decided use custom htmlhelper but at the moment, I can't see checkbox in my page when I remove checkbox word in type="checkbox" it's shown as a textbox I think it's sensitive about type of control that is name checkbox.

 public static class HelperUI
{
    public static MvcHtmlString CheckBoxSimpleFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, bool>> expression, object htmlAttributes)
    {
        string checkBoxWithHidden = htmlHelper.CheckBoxFor(expression, htmlAttributes).ToHtmlString().Trim();
        string pureCheckBox = checkBoxWithHidden.Substring(0, checkBoxWithHidden.IndexOf("<input", 1));
        return new MvcHtmlString(pureCheckBox);
    }
}


 <div class="col-md-6">
     <div class="form-group row">
         <label class="text-right col-md-3">وضعیت</label>

         <div class="col-md-9">

             @Html.CheckBoxSimpleFor(model => model.Status, new { @class = "form-control filled-in" })


         </div>
     </div>
 </div>

Aucun commentaire:

Enregistrer un commentaire