Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Asp.Net MVC and Switch

Chris free asked 4 years ago


I can't seem to get the standard Asp.Net MVC Checkbox and the switch control to work together. I know that MVC spits out two input boxes and maybe that's the problem, but I need some assistance on wiring that up. I've also tried a simple checkbox and it submits "on" instead of "true" like an MVC box.


Grzegorz Bujański staff commented 4 years ago

I'm sorry but we don't have any experience with Asp.Net MVC. It's hard for us to say anything about this.


Vikas lalwani free answered 3 years ago


You can simply Add checkbox CSS and it should work in your MVC app

@Html.CheckBoxFor(m => Model.Checkbox, new { @class = "MDBootstrapclass" })

If this doesn't work, you can also use regular Checkbox with MDBootstrap class

 <label class="checkbox">
    <input data-val="true" 
        data-val-required="The Se souvenir de moi? field is required." 
        id="RememberMe"
        name="RememberMe" 
        type="checkbox"
        value="true"
        @(Model.RememberMe ? "checked" : "")
    ><i></i>@ViewRes.Names.RememberMe
</label>
<input name="RememberMe" type="hidden" value="false">

Check this link: https://forums.asp.net/t/2141802.aspx?My+css+code+does+not+work+with+MVC+checkboxFor

You will need the exact HTML when MVC HTML.Checkboxfor is rendered.

OR you can simply create own custom checkbox by using MDBootstrap CSS properties. HTML Custom Checkbox and Radio buttons


Marcin Luczak staff commented 3 years ago

Hi @Vikas lalwani,

Thank you for your help to our community :)

Keep coding, Marcin from MDB



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.15.0
  • Device: Desktop
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: No
  • Provided link: No