MVC 3 アプリに次のコードがあります。
意見:
@(Html.Telerik().Upload()
.Name("insertAttachement")
.Multiple(false)
.Async(async => async.Save("InsertUpload", "DocumentMaquette"))
.Localizable("fr-CH")
.ClientEvents(events => events
.OnLoad("handleUploadControlLoad")
.OnUpload("handleInsertUpload")
)
)
コントローラーの方法:
public void InsertUpload(HttpPostedFileBase attachement)
{
DocumentMaquetteModel model = new DocumentMaquetteModel();
model.fileName_DMQ = attachement.FileName;
}
JS ファイル イベント ハンドラ:
function handleInsertUpload(e) {
console.log(e.files);
}
function handleUploadControlLoad() {
// handle buttons
$(this).parent().find('.t-button.t-grid-insert, .t-button.t-grid-cancel').remove();
// schedule grid refresh on window close
$(this).closest('.t-window').on('close', refreshGrid);
}
function refreshGrid() {
$('.t-grid').data('tGrid').ajaxRequest();
}
コンソールの出力は次のとおりです。
[Object]
0: Object
extension: ".odt"
name: "ListeDeParticipantsParSP.odt"
rawFile: File
size: 761691
__proto__: Object
length: 1
__proto__: Array[0]
しかし、コントローラーメソッドでは、パラメーターが null であるため、添付ファイルからファイル名を取得しようとすると NullReferenceException 例外が発生します。
これに関する情報は大歓迎です。
ありがとう、シルヴィウ