大家好消息。我再次提问。我有个人信息块,个人信息编辑块和密码块的页面。单击按钮后,我只需要重新加载密码块。但我有一个问题,当我点击按钮时,我的页面尝试重新加载所有页面。并要求再次调用加载个人和密码信息的方法。但是,我只需要在密码块中显示消息并使用密码进行操作,而不会影响个人信息块。 (另外我需要处理个人信息块而不影响密码阻止,但我认为下面的答案也是一样的。)
PersonalInf cotroller:
@using (Html.BeginForm("changePersonalInf", "PersonalPage", FormMethod.Post))
{
@Html.AntiForgeryToken()
<tr>
<td><p>Город:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vCity, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>ФИО:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vFIO, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>Индекс:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vIndex, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>Населенный пункт:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vLocality, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>Улица:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vStreet, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>Дом/корпус/строение:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vHome, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>Квартира:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vApartment, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><p>Телефон:</p></td>
<td>@Html.EditorFor(model => model.personalInfModel.vPhone, new { htmlAttributes = new { @class = "form-control" } })</td>
</tr>
<tr>
<td><input type="submit" value="Изменить" class="btn-problem" /></td>
<td><input type="reset" value="Очистка" class="btn-problem" /></td>
</tr>
}
并查看代码,代码如autherize form:
visible="{= ${viewModel>/selectedTabKey} === 'aaa' && ${viewModel>/editMode} === true}"
答案 0 :(得分:0)
将更改密码块放在部分视图中,并将表单更改为Ajax格式:
@using (Html.BeginForm("changePersonalInf", "PersonalPage", FormMethod.Post)) {
}
到
@using (Ajax.BeginForm("changePersonalInf", "PersonalPage", null, new AjaxOptions {
UpdateTargetId = "id_of_your_change_password_block"
}, new { role = "form", id = "AssignCoachForm" })) {
}
这将自动更新具有给定ID的块。或者,您可以在JavaScript中自己完成这项工作并对其进行更多控制:
@using (Ajax.BeginForm("changePersonalInf", "PersonalPage", null, new AjaxOptions {
OnSuccess = "your_js_success_function(data);",
OnFailure = "your_js_failure_function();",
}, new { role = "form", id = "AssignCoachForm" })) {
}