This is a migrated thread and some comments may be shown as answers.

Uploaded file not passes to Action (controller)

2 Answers 48 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Silver Lightning
Top achievements
Rank 1
Silver Lightning asked on 02 Jun 2014, 11:47 PM


Hi Sir

I used async upload, on my view I used the event select and upload function. the problem is the request not sent to the Action once I uploaded a file.

Here's my code snippet.



 $(document).ready(function () {



var lookup = $("#ComboLookupTable").data("kendoComboBox");
$("#get").click(function () {
});

$("#files").kendoUpload({
async: {
saveUrl: "UploadFile/Lookup",
removeUrl: "remove",
autoUpload: false,
value: 'Import'
},
multiple: false,
progress: function (e) {

},
upload: function (e) {
// debugger;
var kendoWindow = $("<div />").kendoWindow({
title: "Replace Lookup Table Data?",
resizable: false,
modal: true
});

kendoWindow.data("kendoWindow")
.content($("#delete-confirmation").html())
.center().open();

kendoWindow
.find(".delete-confirm,.delete-cancel")
.click(function () {
if ($(this).hasClass("delete-cancel")) {

e.preventDefault();
// kendoWindow.data("kendoWindow").close();
//return;
}
else {
e.data = { additional: $("#ComboLookupTable").val() };
}

kendoWindow.data("kendoWindow").close();
})
//.end()



// ---------

//e.data = { additional: $("#ComboLookupTable").val() };
},
select: function (e) {
// debugger;
e.data = { additional: $("#ComboLookupTable").val() };
},
localization: {
select: "Select a file",
uploadSelectedFiles: "Import",
remove: "Remove"
}
//upload: onUpload
//select: onSelect

});
});


Here's my controller (action)

'Upload File (excel)
<HttpPost> _
Public Function UploadFile(ByVal files As HttpPostedFileBase, ByVal additional As String) As ActionResult

Dim data = (New ExcelReader()).ReadExcel(files)

Select Case additional
Case FuelEfficiencyViewModel.Table.Lookup.ConversionFactors
Return View()
Case FuelEfficiencyViewModel.Table.Lookup.ElectricalRegionalEmissionFactors
Return View()
Case FuelEfficiencyViewModel.Table.Lookup.ElectricalSubRegionEmissionFactors
Return View()
Case FuelEfficiencyViewModel.Table.Lookup.FuelEfficiecies
Dim ent As New List(Of ViewModel.FuelEfficiencyViewModel.Create)

For Each datarow In data.DataRows
ent.Add(New ViewModel.FuelEfficiencyViewModel.Create With {.VehicleClass = datarow(0).ToString, _
.FuelEfficiencyValue = Convert.ToDecimal(datarow(1)), _
.CreatedBy = Session(LocalConstant.Ses_UserID), _
.CreatedDate = Now.Date})
Next
_fuelefficiencyRepository.Create(ent)
Return View()
Case FuelEfficiencyViewModel.Table.Lookup.GlobalEmissionFactors
Return View()
Case FuelEfficiencyViewModel.Table.Lookup.GlobalWarmingPotential
Return View()

End Select


'Session(LocalConstant.SessionExcelData) = resultList

Return View("Index", data.Status)
'Return View()
End Function



Thank you in advance and God bless.

2 Answers, 1 is accepted

Sort by
0
Silver Lightning
Top achievements
Rank 1
answered on 03 Jun 2014, 06:10 AM
I solved it. Thanks
0
Dimiter Madjarov
Telerik team
answered on 03 Jun 2014, 08:24 AM
Hello Jesureno,


Nice to hear the problem is solved. Let us know if you experience any further issues.

Have a great day!

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Upload
Asked by
Silver Lightning
Top achievements
Rank 1
Answers by
Silver Lightning
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or