0

I have a form in the view section that has a checkbox type input

<div class="checkbox">
<label class="">active</label>
<div class="icheckbox_flat-green checked" style="position: relative;">
<input type="checkbox" id="AdvActive" name="AdvActive" class="flat" checked="checked"/>
</div>                            
</div>   

And through the ajax code below I send the values ​​to the controller

$.ajax({
  type: "post",
  url: '@Url.Action("CreateAdvBanner", "Advertise")',
  cache: false,
   data: form.serialize()
})

All form values ​​are sent to the controller except the same checkbox. Do I want to send "True" to the controller when the checkbox is checked? This is my controller

[HttpPost]
public IActionResult CreateAdvBanner(string AdvCode, int AdvPrice ,int AdvDay, string AdvDesc,bool AdvActive)
{

3

1 Answer 1

1

Send JSON to controller

something like

$.ajax({
  type: "post",
  url: '@Url.Action("CreateAdvBanner", "Advertise")',
  cache: false,
  data: {"AdvCode" : "itsValue", "AdvPrice":"itsValue", "AdvDay" : "itsValue", "AdvDesc" : "somevalue"}  
})

boolean values and numbers mustn't be in ""

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.