尝试通过 Ajax.BeginForm 更新对象上的 属性,但提交后对象上的所有其他 属性 均为空
Trying to update a property on an Object via Ajax.BeginForm, but every other property on Object is null after submit
我正在尝试使用以下 Razor 代码更新 PaymentNotificationEmail 并且仅更新 PaymentNotificationEmail:
@using (Ajax.BeginForm("Save", "PaymentLandingPage", new AjaxOptions
{
HttpMethod = "Post",
InsertionMode = InsertionMode.Replace,
}))
{
<table class="PEmailFields">
<tr>
<td>
<div style="float:left;">
<ul style="list-style-type: none;">
<li><span id="PEmaillbl">Payment Notification Email:</span></li>
<li><br /></li>
</ul>
</div>
<div style="float:right;">
<ul style="list-style-type: none;">
@Html.HiddenFor(m => m.PrimaryNamedInsured)
<li>@Html.TextBoxFor(m => m.PaymentNotificationEmail, new { @id = "PEmailtxbx", placeholder = "Example: ppp@test.com", maxlength = "100", style = "margin-left:25px;min-width:530px;", Value = Model.PrimaryNamedInsured.PrimaryEmail })</li>
<li><span id="PEmaildsclmr" data-PEmailValue="@Model.PaymentNotificationEmail"><i style="margin-left:190px;font-size:small;">* This email address is used for payment notifications.</i></span></li>
</ul>
</div>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
<input style="margin-left:35%;" type="submit" value="Save Email" />
}
我 运行 遇到的问题是,当我到达控制器时,对象只有 PaymentNotificationEmail。对象上的所有其他内容都是 Null。
如何更新 PaymentNotificationEmail 而不会丢失@Model 中已有的信息?
经过大量研究和故障排除后,我们重新设计了整个问题,这个问题变得无关紧要了。最终的答案是我们的设计一开始就很糟糕。
我正在尝试使用以下 Razor 代码更新 PaymentNotificationEmail 并且仅更新 PaymentNotificationEmail:
@using (Ajax.BeginForm("Save", "PaymentLandingPage", new AjaxOptions
{
HttpMethod = "Post",
InsertionMode = InsertionMode.Replace,
}))
{
<table class="PEmailFields">
<tr>
<td>
<div style="float:left;">
<ul style="list-style-type: none;">
<li><span id="PEmaillbl">Payment Notification Email:</span></li>
<li><br /></li>
</ul>
</div>
<div style="float:right;">
<ul style="list-style-type: none;">
@Html.HiddenFor(m => m.PrimaryNamedInsured)
<li>@Html.TextBoxFor(m => m.PaymentNotificationEmail, new { @id = "PEmailtxbx", placeholder = "Example: ppp@test.com", maxlength = "100", style = "margin-left:25px;min-width:530px;", Value = Model.PrimaryNamedInsured.PrimaryEmail })</li>
<li><span id="PEmaildsclmr" data-PEmailValue="@Model.PaymentNotificationEmail"><i style="margin-left:190px;font-size:small;">* This email address is used for payment notifications.</i></span></li>
</ul>
</div>
</td>
</tr>
<tr>
<td></td>
</tr>
</table>
<input style="margin-left:35%;" type="submit" value="Save Email" />
}
我 运行 遇到的问题是,当我到达控制器时,对象只有 PaymentNotificationEmail。对象上的所有其他内容都是 Null。
如何更新 PaymentNotificationEmail 而不会丢失@Model 中已有的信息?
经过大量研究和故障排除后,我们重新设计了整个问题,这个问题变得无关紧要了。最终的答案是我们的设计一开始就很糟糕。