【问题标题】:Popup containt become blank at the time of moving the popup positions by selecting popup header通过选择弹出标题移动弹出位置时弹出内容变为空白
【发布时间】:2014-01-24 18:38:19
【问题描述】:

我正在使用弹出窗口的 ContentUrl 属性将视图打开到弹出窗口控件中。 但是当我尝试通过选择弹出标题来移动弹出的位置时。弹出包含仍然空白我正在移动或选择弹出标题。在线提供的 devexpress 演示中也存在同样的问题。

我参考了以下 devexpress 弹出控件的演示 http://demos.devexpress.com/MVCxDockAndPopupsDemos/PopupControl/ContentUrl

我写了以下代码 家庭控制器

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; }
}

索引.chtml

   @{
    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("SendProduct", "Home");
        settings.ShowLoadingPanel = true;
        settings.ClientSideEvents.BeginCallback = "OnBeginCallback";
    }).GetHtml()

发送Product.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")

在上面的代码中,当我单击按钮弹出窗口时,会在 brouser 上正确打开。但是当我选择弹出标题来更改位置位置或任何原因弹出包含将消失或弹出将显示空白包含。当我取消选择弹出标题弹出窗口时,弹出窗口包含视图显示

请给我解决方案,以便当用户选择弹出标题时弹出包含不会变成空白。弹出窗口必须显示视图。

【问题讨论】:

  • 我在我的项目中复制了您的 PopupControl 设置,但在 Chrome 和 IE11 中没有发现该行为。您是否注册了所有 DevExpress 样式和脚本(Html.DevExpress().GetStyleSheets 和 GetScripts)?
  • 谢谢重播 误会我评论了 settings.ContentUrl = Url.Action("SendProduct", "Home");代码进入弹出窗口,所以请取消注释该代码以打开视图进入弹出窗口。之后,您将获得该空白包含条件
  • 现在我复制了它。我解释了为什么会发生这种情况。

标签: asp.net-mvc-4 popup devexpress


【解决方案1】:

Heredevexress 团队六年前给出了一个解释,当你使用 ContentUrl 属性时这是不可能的,因为控件在 iframe 中呈现它。

您可以在 ViewContext 中编写视图内容,但您的控制器应该返回 PartialView。

public class HomeController : Controller
{
    public ActionResult SendProduct(string rowId)
    {
        Product objProduct = new Product();
        return PartialView(objProduct);
    }

    [HttpPost]
    public ActionResult SendProduct(Product objProduct)
    {
        return PartialView(objProduct);
    }
 }

弹出设置

    settings.SetContent(() =>
    {
        ViewContext.Writer.Write((Html.Action("SendProduct", "Home").ToHtmlString()));
    });
    //settings.ContentUrl = Url.Action("SendProduct", "Home");

【讨论】:

    猜你喜欢
    • 2017-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-26
    相关资源
    最近更新 更多