对于您无法解决的问题,我需要您的帮助:)我的程序中有此表格可以上传文件@using(Html.BeginForm("UploadDocuments", "User", FormMethod.Post, new { enctype = "multipart/form-data", id = "form-upload-documents" })){ @Html.AntiForgeryToken() <ul id="UploadContainer" class="upload-container" data-last-id="0"> <li class="col-upload-figure"> <figure class="upload-figure"> <label class="btn-upload" for="Picture_0"> <span class="btn-upload-text">Add a picture</span> </label> <input class="custom-input-file" data-id="0" id="Picture_0" name="Picture_0" type="file"> </figure> </li> </ul> <div class="form-submit"> <button class="btn btn-primary btn-loader" data-style="expand-right" type="submit">Submit</button> </div>}然后检查要使用javascript上传的文件的大小,如果文件太大,我想在不离开当前页面的情况下调用C#类的void方法 $('#Picture_0').change(function() { var files = $(this).prop('files'); var fullPath = $(this).val(); if (files[0].size > 4*1024*1024) { $('#Picture_0').val('')*; // The function of a specific class I would like to call } else{ //... } })我该怎么做呢?
3 回答
精慕HU
TA贡献1845条经验 获得超8个赞
一个ajax调用可以解决这个问题。就像是:
$.ajax({
url:'@Url.Action("Action", "controller")',
type: 'POST',
data: //Your data, //Possibly a json
contentType: 'Application/json',
success: function(result)
{
}
});
肥皂起泡泡
TA贡献1829条经验 获得超6个赞
你可以用ajax来称呼它,
public ActionResult MethodName()
{
// your logic
EmptyResult e = new EmptyResult();
return e;
}
- 3 回答
- 0 关注
- 233 浏览
添加回答
举报
0/150
提交
取消