我有包含gridview的父页面。当我右键单击网格视图中的任何行时,上下文菜单将打开。通过选择上下文菜单,我想用强类型视图打开弹出窗口。我有一个强类型视图的打开弹出窗口。 但问题是我必须将数据成员创建到父视图模型中以将模型对象传递给弹出视图。我不希望我想调用特定动作来打开弹出窗口的视图。因为一个父视图可以打开多个弹出窗口,所以对于所有弹出窗口我必须在父视图模型中创建一个数据成员。 例如 我想通过从网格中选择客户记录来打开发送产品信息弹出窗口。
控制器
public class ProductController : Controller
{
public ViewResult SendProductInformation()
{
ProductModel objProductModel = new ProductModel ();
return View(objProductModel );
}
[HttpPost]
public ViewResult SendProductInformation()
{
ProductModel objProductModel = new ProductModel ();
return View(objProductModel );
}
}
查看
@model UI.Areas.Product.ModelsProductModel
@{
ViewBag.Title = "Product ";
}
<h2>Edit</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>EmployeeModel</legend>
<div class="editor-label">
@Html.LabelFor(model => model.EmployeeId)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.EmployeeId)
@Html.ValidationMessageFor(model => model.EmployeeId)
</div>
<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>
}
从父视图我打开popup controal以下是popup controal
@Html.DevExpress().PopupControl(
settings =>
{
settings.Name = "pcSendProductInformation";
settings.Width = 1000;
settings.Height = 350;
settings.HeaderText = "Send Product Information";
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.SetContent(() =>
Html.RenderAction("SendProductInformation","Product")
);
}).GetHtml()
但是当我使用Html.RenderAction(“SendProductInformationl”,Model.productInfo)时,popup controal会给出Html.RenderAction(“SendProductInformation”,“Product”)的错误。 但我必须传递模型对象。
Please give me solution to open popup with strongly type view by calling SendProductInformation action method .
答案 0 :(得分:0)
这是因为“Product”作为参数传递给控制器。尝试这样的Html.RenderAction(actionName: "action", controllerName: "controller")