I have a modal register that I get 2 values, I use an AJAX to save the information, however the value of @Html.DropDownList
does not go to my Controller, the strange is the value of the Description arrives in the controller.
<div class="modal-body">
<div class="form-horizontal">
@Html.ValidationSummary(true)
<div class="form-group">
@Html.Label("Descrição", new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.TextBoxFor(model => model.Descricao, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Descricao)
</div>
</div>
<div class="form-group">
@Html.Label("Tipo de Cálculo", new { @class = "control-label col-md-3" })
<div class="col-md-9">
@Html.DropDownList("TipoCalculo")
</div><br />
</div>
</div>
</div>
<script>
$(document).ready(function () {
//$("#AjaxPost").click(function () {
//alert($('#TipoCalculo :selected').val())
$("#AjaxPost").click(function () {
var dataObject = {
Descricao: $("#Descricao").val(),
TipoCalculo: $('#TipoCalculo :selected').text(),
};
$.ajax({
url: "@Url.Action("SalvarMilestone", "Dashboard")",
type: "POST",
data: dataObject,
dataType: "json"
});
});
});