将 ASP.net 控件添加到 JQuery 对话框无法正确呈现

发布于 2024-12-10 01:53:57 字数 2405 浏览 0 评论 0原文

您好,我见过很多与此类似的问题,但所有问题都已通过将对话框添加回页面的主窗体中来解决。这不能解决以下问题:

在我的 Aspx 文件中,我定义了一段代码,如下所示:

    <asp:UpdatePanel runat="server" ID="RadAjaxPanel2" UpdateMode="always">
        <ContentTemplate>
            <div id="areaFilterDialog" runat="server">
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

并且我有以下 javascript / jquery 来初始化对话框

 $("#areaFilterDialog").dialog({
                    bgiframe: true,
                    autoOpen: false,
                    resizable: false,
                    modal: true,
                    draggable: true,
                    closeOnEscape: true,
                    width: 630,
                    open: function (type, data) {
                        dialogOpen = true;
                        $(this).parent().appendTo("form");
                    }
                });
        });

,该对话框将对话框的元素附加到父级的表单中页。

在 .cs 文件中,我将内容添加到元素中,如下所示:

var departmentCode = e.DepartmentCode;
var summaryType = e.SummaryType;
var summaryCode = e.SummaryCode;
var totalName = e.TotalName;
var view = this.TemplateControl.LoadControl(".\\WebControls\\FilteredAreaRadGrid.ascx") as FilteredAreaRadGrid;

using (var businessManager = new BusinessManager(new DALConnection(this.DalConnectionString)))
{
       view.DataSource = businessManager.GetData(departmentCode, summaryType, summaryCode, string.Empty);
       this.AreaFilterDialog.Controls.Add(view);
}

并通过使用 ScriptManager 注册以下启动脚本来显示 JQuery UI 对话框:

 var script = string.Format("ShowAttendanceFilterPopup('{0}');", totalName);
 ScriptManager.RegisterStartupScript(
      this.Page,
      this.Page.GetType(),
      "tmp",
      string.Format("<script type='text/javascript'>{0}</script>", script),
      false);

它调用以下 javascript/jquery:

function ShowAttendanceFilterPopup(summaryName) {
    $("#areaFilterDialog").data('title.dialog', summaryName);
    $('#areaFilterDialog').dialog("open");
    $('#areaFilterDialog').dialog("enable");
}

问题是 html 应该具有附加到对话框实际上只是附加到页面顶部,并且根本不显示对话框。如果我在显示之前将控件添加到对话框中,则对话框将正确显示。

我已经尝试过使用当前添加的内容,即包含 Telerik RadGrid 的 UserControl,但也包含标准的 asp 按钮,并且两者具有相同的行为。

有人对我做错了什么或者更好的事情有任何想法,解决这个问题吗?

非常感谢,

罗布

Hi I've seen quite a few similar questions to this but all have been resolved by adding the dialog back into the page's main form. This doesn't resolve the following problem:

In my Aspx file, I've defined a segment of code as following:

    <asp:UpdatePanel runat="server" ID="RadAjaxPanel2" UpdateMode="always">
        <ContentTemplate>
            <div id="areaFilterDialog" runat="server">
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

and I've got the following javascript / jquery to initialise the dialog

 $("#areaFilterDialog").dialog({
                    bgiframe: true,
                    autoOpen: false,
                    resizable: false,
                    modal: true,
                    draggable: true,
                    closeOnEscape: true,
                    width: 630,
                    open: function (type, data) {
                        dialogOpen = true;
                        $(this).parent().appendTo("form");
                    }
                });
        });

which appends the dialog's element to the form on the parent page.

In a .cs file, I add content to the element as follows:

var departmentCode = e.DepartmentCode;
var summaryType = e.SummaryType;
var summaryCode = e.SummaryCode;
var totalName = e.TotalName;
var view = this.TemplateControl.LoadControl(".\\WebControls\\FilteredAreaRadGrid.ascx") as FilteredAreaRadGrid;

using (var businessManager = new BusinessManager(new DALConnection(this.DalConnectionString)))
{
       view.DataSource = businessManager.GetData(departmentCode, summaryType, summaryCode, string.Empty);
       this.AreaFilterDialog.Controls.Add(view);
}

and I make the JQuery UI Dialog show by registering the following startup script with the ScriptManager:

 var script = string.Format("ShowAttendanceFilterPopup('{0}');", totalName);
 ScriptManager.RegisterStartupScript(
      this.Page,
      this.Page.GetType(),
      "tmp",
      string.Format("<script type='text/javascript'>{0}</script>", script),
      false);

which calls the following javascript / jquery:

function ShowAttendanceFilterPopup(summaryName) {
    $("#areaFilterDialog").data('title.dialog', summaryName);
    $('#areaFilterDialog').dialog("open");
    $('#areaFilterDialog').dialog("enable");
}

The problem is that the html which should have been appended to the dialog is actually just appended to the top of the page, and the dialog box is not shown at all. If i don't add a Control to the dialog before I show it, the dialog displays correctly.

I've tried this with what I add currently, which is a UserControl containing a Telerik RadGrid, but also with a standard asp button, and both have the same behaviour.

Anyone got any ideas to what I'm doing incorrectly or even better, a solution to this problem?

Thanks a lot,

Rob

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

や莫失莫忘 2024-12-17 01:53:57

也许尝试一下:

<div id="areaFilterDialog">
    <asp:UpdatePanel runat="server" ID="RadAjaxPanel2" UpdateMode="always">
        <ContentTemplate></ContentTemplate>
    </asp:UpdatePanel>
</div>

我没有使用过 Telerik Ajax 面板,但我猜想是这样的:

using (var businessManager = new BusinessManager(new DALConnection(this.DalConnectionString)))
{
       view.DataSource = businessManager.GetData(departmentCode, summaryType, summaryCode, string.Empty);
       RadAjaxPanel2.Controls.Add(view);
}

将 div 放在 AjaxPanel ContentTemplate 中并向其中添加视图控件对我来说似乎并不正确。

Perhaps try:

<div id="areaFilterDialog">
    <asp:UpdatePanel runat="server" ID="RadAjaxPanel2" UpdateMode="always">
        <ContentTemplate></ContentTemplate>
    </asp:UpdatePanel>
</div>

I've not used the Telerik Ajax Panels but I'm guessing something like:

using (var businessManager = new BusinessManager(new DALConnection(this.DalConnectionString)))
{
       view.DataSource = businessManager.GetData(departmentCode, summaryType, summaryCode, string.Empty);
       RadAjaxPanel2.Controls.Add(view);
}

Having the div inside the AjaxPanel ContentTemplate and adding the view Control to it just doesn't seem right to me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文