Javascript 如何使用html.beginform从服务器端获取结果?
我需要从服务器端获取结果。但是我使用的是HTml.Begin表单。下面给出了我的示例代码Javascript 如何使用html.beginform从服务器端获取结果?,javascript,asp.net-mvc,asp.net-mvc-3,html.beginform,Javascript,Asp.net Mvc,Asp.net Mvc 3,Html.beginform,我需要从服务器端获取结果。但是我使用的是HTml.Begin表单。下面给出了我的示例代码 @using (Html.BeginForm("actionname", "contollerr", FormMethod.Post, new { enctype = "multipart/form-data" })) { } public ActionResult actionname(IEnumerable<HttpPostedFileBase> files) { mess
@using (Html.BeginForm("actionname", "contollerr", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
}
public ActionResult actionname(IEnumerable<HttpPostedFileBase> files)
{
message = "your load in failed";
return Json(new { success = false, message });
}
@使用(Html.BeginForm(“actionname”、“contollerr”、FormMethod.Post、new{enctype=“multipart/formdata”}))
{
}
公共ActionResult actionname(IEnumerable文件)
{
message=“您的加载失败”;
返回Json(新的{success=false,message});
}
如何从控制器获取结果数据 您没有使用ajax,因此这段代码不起作用,您需要这样的验证摘要:我假设生成表单视图的操作和提交方法的操作具有相同的名称
@using (Html.BeginForm("actionname", "contollerr", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
}
public ActionResult actionname(IEnumerable<HttpPostedFileBase> files)
{
message = "your load in failed";
ModelState.AddModelError(string.Empty, message );
return View();
}
@使用(Html.BeginForm(“actionname”、“contollerr”、FormMethod.Post、new{enctype=“multipart/formdata”}))
{
@Html.ValidationSummary(true)
}
公共ActionResult actionname(IEnumerable文件)
{
message=“您的加载失败”;
AddModelError(string.Empty,message);
返回视图();
}
您是否通过ajax上传文件?不,我只是通过html.begin上传文件