我有这样的看法:
<div id="basic-information-container">
@Html.Action("MyBasicInformation")
</div>
<div id="cv-container">
@Html.Action("MyCv")
</div>
<div id="experiance-container">
@Html.Action("MyExperiances")
</div>
<div id="academic-background-container">
@Html.Action("MyAcademicBackgrounds")
</div>
部分视图 MyCv 是:
@model Model.Profile.CvModel
<script type="text/javascript">
$(function () {
$("#cv-container form").submit(function () {
$(this).ajaxSubmit({
target: "#cv-container",
cache: false
});
return false;
});
});
</script>
@using(Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Cv</legend>
@Html.EditorFor(model => model.File)
@* I have working editor template for HttpPostedFileBase, nothing to worry about this*@
@Html.ValidationMessageFor(model => model.File)
<p>
<input type="submit" value="Upload" />
</p>
</fieldset>
}
这是 CvModel 的代码
public class CvModel {
public int? Id { get; set; }
[Required]
public HttpPostedFileBase File { get; set; }
public CvModel() {
}
public CvModel(int? cvId) {
Id = cvId;
}
}
这是 MyCv 的 post 方法
[HttpPost]
public ActionResult MyCv(CvModel model) {
// upload cv to database
return PartialView(model);
}
现在,问题是,当我出于某种未知原因上传 CV 时,部分视图MyBasicInformation, MyExperiances and MyAcademicBackgrounds
正在重新加载。我找不到我做错了什么。我在哪里做错了?
顺便说一句,我已经确认MyBasicInformation, MyExperiances and MyAcademicBackgrounds
没有调用 get 操作。视图正在直接重新加载。