This is the situation:
I have a form that when i click in the submit button is sending a file
with the kendo upload control, and the method action of the controller
is receiving that file in the parameter with the HttpPostedFileBase.
This is my HTML code:
@using (Html.BeginForm("ConfirmarOposicion", "Gestion", FormMethod.Post, new { @id = "Frm-login", role = "form", @class = "form-horizontal" }))
{
@(Html.Kendo().Upload()
.Name("files")
)
<button class="btn btn-success" type="submit" id="confirm" >Confirm</button>
}
And this is my controller:
public async Task<ActionResult> ConfirmarOposicion(IEnumerable<HttpPostedFileBase> files)
{
// Here the parameter files is not null..
}
Here is working all good till now. The problem is when i try to send
more values as parameter into the same method of the controller.
The other values that i want to send is an array, and the other is a
number.
This two values i try to send with ajax in javaScript.
This is my javaScript code when i try to send those two more values:
$("#confirm").click(function ()
{
var numMarca = $("#numMarca").val()
var idsToSend = [];
var grid = $("#Grid2").data("kendoGrid")
var ds = grid.dataSource.view();
for (var i = 0; i < ds.length; i++)
{
var row = grid.table.find("tr[data-uid='" + ds[i].uid + "']");
var checkbox = $(row).find(".checkbox");
if (checkbox.is(":checked"))
{
idsToSend.push(ds[i].DescMarca);
idsToSend.push(ds[i].IntencionOposicion = 1);
}
else
{
idsToSend.push(ds[i].DescMarca);
}
}
$.ajax({
url: '@Url.Action("ConfirmarOposicion", "Gestion")',
data: { ids: idsToSend, marca: numMarca },
type: 'POST',
dataType: "json",
success: function (data)
{
...
}
When i clik the submit button is sending this two values in the same controller that i send the input file.
And this my controller now:
public async Task<ActionResult> ConfirmarOposicion(IEnumerable<HttpPostedFileBase> files, string[] ids, string marca)
{
// here the array ids and the value of marca is not null, but the parameter files it is null
}
And that's the issue that i have.
I need to send all those values in the same method action of the controller.
How can i do that?