I have the following button which imports a file. I am passing the file to a function, but I also need to pass an id from the model of the view which I am checking if it is null before showing the import button (Model.OrganizationId)
@if (Model.OrganizationId != null)
{
<input type="file" id="fileInput" value="Import" style="display: none;" onchange="uploadFile(this)" />
<input class="buttons import" style="width: 12.5em" readonly="readonly" onclick="document.getElementById('fileInput').click();" value="Import" />
}
This is the uploadFile function:
function uploadFile(fileCtrl,id) {
showLoading();
var formData = new FormData();
if (fileCtrl.files.length > 0) {
formData.append('Excel', fileCtrl.files[0]);
$.ajax({
url: actionUrl("Action", "Controller", null, "Area"),
type: "POST",
cache: false,
contentType: false,
processData: false,
data: formData,
success: function (data) {
---------
How can I pass that second parameter so my controller
public JsonResult Import(FormCollection form, long? organizationId)
{
can take that organizationId?