I try to passing a parameter to simply action that return a partial view in a popup, but I can't to passing the parameters, and as if it did not arrive at the action.
I don't understand why???
I use .net core 2.
this my code.
The action
[HttpPost]
public IActionResult Detail([FromBody] string tableName, [FromBody] string code)
{
var row = tableBLL.GetAllByCode(tableName, code);
return PartialView("~/Views/Table/Detail.cshtml");
}
The jquery function. The value patamenter are hard coded to try the operation, after I should recover them from the table
$("#dt_basic a.details").click(function() {
$.ajax({
method: "POST",
url: "/Table/Detail",
data: JSON.stringify({
"tableName": "IN_COMAGREE",
"code": "1"
}),
//data: '{code: "' + codeId + '" }',
contentType: "application/json",
//dataType: "html",
success: function (response) {
$('#dialog').html(response);
$('#dialog').dialog('open');
},
failure: function (response) {
alert(response.responseText);
},
error: function (response) {
alert(response.responseText);
}
});
});
The Partial view ( very simple in this moment )
<form asp-action="" class="smart-form">
<header>
Name table
</header>
<fieldset>
<section>
<label class="label">Cod</label>
<label class="input">
<input type="text" class="input-xs">
</label>
</section>
<section>
<label class="label">Descr</label>
<label class="input">
<input type="text" class="input-xs">
</label>
</section>
</fieldset>
</form>
Point of the call to the function
<table id="dt_basic" class="table table-striped table-bordered table-hover" width="100%">
<thead>
<tr>
@foreach (DataColumn col in Model.Columns)
{
<th>@col.ColumnName</th>
}
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (DataRow row in Model.Rows)
{
<tr>
@foreach (DataColumn col in Model.Columns)
{
<td>@row[col.ColumnName]</td>
}
<td>
<a href="#" class="details"> Edit @row[0]</a>
<a href="#" class="btn bg-color-red txt-color-white btn-xs"> Delete @row[0]</a>
</td>
</tr>
}
</tbody>
</table>