0
我创建了一个局部视图,并在其中使用了AJAx.BeginForm。在Post Edit Action Method中,我添加了VIEWDATA像这样ViewData不在Ajax.BeginForm中显示
if (ModelState.IsValid)
{
service.SaveAccount(account);
TempData["message"] = "Account has been updated successfully!";
AccountInfo accountInfo = new AccountInfo();
accountInfo.AccountStatuses = service.GetAccountStatuses();
accountInfo.AccountTypes = service.GetAccountTypes();
accountInfo.CreditTerms = service.GetCreditTerms();
return View("DisputeSubscriber", accountInfo);
}
else
{
return PartialView("_UpdateAccountDetails", account);
}
并重定向到相同的局部视图。在部分视图中,我已添加像这样:
@if (TempData["message"] != null)
{
<div class="Message">
I am here.
@TempData["message"]
</div>
}
但此消息不显示。这个消息也在AJAX.BeginForm里面。请建议
我需要重定向,而不是局部视图主视图或有我丢失的东西
我已经使用UpdateTargetId很好,但它没有显示在div。我看到该记录已更新。我使用了警报,并显示错误警报。 “@using(Ajax.BeginForm(”UpdateAccountDetails“,new AjaxOptions {OnSuccess =”alert('done')“,OnFailure =”alert('Error');“}))” – DotnetSparrow
@DotnetSparrow,元素更新后所有当你使用UpdateTargetId?我不是在谈论TempData问题。在部分中放入一些虚拟数据,并确保它首先更新。 –
您可以举一个如何更新targetid>的例子吗?我只是将updateTargetId设置为我想要更新 – DotnetSparrow