Generating two CheckBox tags being one hidden in AspNet MVC

1

Good Night

@Html.CheckBox("Agree", new { value = false, @class = "filled-in", @id = "filled-in-box" })

When I generate the CheckBox in AspNet, by the above command, it is generating me two Tags being one is Hidden, as I am using the materialize css, it is getting bugged, throwing the CheckBox left to -9999, removing the Hidden node layout is correct, is it possible that it does not generate this Tag Input Hidden?

 <input class="filled-in" id="filled-in-box" name="Agree" value="False" type="checkbox">
 <input name="Agree" value="false" type="hidden">

So far, the option I had was to create an extension method that removes the Hidden tag

public static MvcHtmlString RemoveHiddenTag(this MvcHtmlString pValue) 
{ 
    const string pattern = @"<input name=""[^""]+"" type=""hidden"" value=""false"" />"; 
    string result = Regex.Replace(pValue.ToString(), pattern, ""); 
    return MvcHtmlString.Create(result); 
} 
    
asked by anonymous 22.09.2016 / 03:42

0 answers