我创建了包含带有提交按钮的强类型视图的弹出窗口。当用户单击提交按钮时,我将以 post 操作方法将数据保存到数据库中。现在我想在保存数据时关闭该弹出窗口并显示打开该弹出窗口的父页面。
以下是代码 HomeController
public class HomeController : Controller
{
public ActionResult SendProduct(string rowId)
{
Product objProduct = new Product();
return View(objProduct);
}
[HttpPost]
public ActionResult SendProduct(Product objProduct)
{
return View(objProduct);
}
}
产品型号
public class Product
{
public int ProductId { get; set; }
[Required]
public string Name { get; set; }
}
索引.chtm
@{
ViewBag.Title = "Home Page";
}
@using DevExpress.Web.Mvc.UI
@using DevExpress.Web.ASPxGridView
@using UI.Infrastructure.Resources;
<script type="text/javascript">
function OnBeginCallback(s, e) {
e.customArgs["rowId"] = 123;
}
function Click() {
pcSendProduct.PerformCallback();
if (!pcSendProduct.IsVisible())
pcSendProduct.Show();
}
</script>
<a href="javascript:Click()">Enumalate menu click</a>
<div>
@Html.DevExpress().Button(settings =>
{
settings.Name = "btnSend";
settings.Width = 80;
settings.Text = "Find";
settings.UseSubmitBehavior = false;
settings.ClientSideEvents.Click = string.Format("function(s, e) {{ Click(); }}");
}).GetHtml()
</div>
@Html.DevExpress().PopupControl(
settings =>
{
settings.Name = "pcSendProduct";
settings.Width = 1050;
settings.Height = 550;
settings.HeaderText = "Plan Customer Interaction";
settings.CloseAction = DevExpress.Web.ASPxClasses.CloseAction.CloseButton;
settings.Styles.Header.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
settings.Styles.Header.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
settings.Styles.Header.Font.Size = 10;
settings.Modal = true;
settings.ShowHeader = true;
settings.ShowCloseButton = true;
settings.CloseAction = DevExpress.Web.ASPxClasses.CloseAction.CloseButton;
settings.Left = 1245;
settings.Top = 300;
settings.Styles.ModalBackground.BackColor = System.Drawing.Color.Transparent;
settings.ContentUrl = Url.Action("PlanCustomerInteraction", "PlanCustomerInteraction");
settings.ShowLoadingPanel = true;
settings.ClientSideEvents.BeginCallback = "OnBeginCallback";
settings.ClientSideEvents.EndCallback = "OnPopupEndCallback";
}).GetHtml()
发送产品.cshtml
@model Demo.Models.Product
@{
ViewBag.Title = "SendProduct";
}
<h2>SendProduct</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Product</legend>
@Html.HiddenFor(model => model.ProductId)
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
因此,在 SendProduct POST 操作方法中保存数据后,我想关闭发送产品弹出窗口。
请给我解决方案以从控制器操作方法中关闭弹出控件。</p>