日期:2014-05-17 浏览次数:20505 次
@using (Html.BeginForm("edit", "Cpxx", FormMethod.Post, new { name = "form1", id = "form1", enctype = "multipart/form-data" }))
{
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.Id)
<ul id="editTable">
<li><div class="label">@Html.LabelFor(model => model.Mc):</div>@Html.EditorFor(model => model.Mc)@Html.ValidationMessageFor(model => model.Mc)</li>
<li><div class="label">@Html.LabelFor(model => model.Cplb):</div>@Html.DropDownListFor(model => model.Cplb,(IEnumerable<SelectListItem>)ViewBag.list)@Html.ValidationMessageFor(model => model.Cplb)</li>
<li><div class="label">@Html.LabelFor(model => model.Tpdz):</div>
<input type="file" name="file" /><br />
<input type="submit" value="文件上传" />
}
#region 上传
[HttpPost]
public ViewResult Upload()
{
HttpPostedFileBase file = Request.Files["file"];
//存入文件
if (file.ContentLength > 0)
{
file.SaveAs(Server.MapPath("~/") + System.IO.Path.GetFileName(file.FileName));
}
ViewBag.FileName = System.IO.Path.GetFileName(file.FileName);
return View();
}
#endregion