【问题标题】:DevExpress Web User Control - Create MessageBox, ConfirmBox?DevExpress Web 用户控件 - 创建 MessageBox、ConfirmBox?
【发布时间】:2012-01-03 18:03:15
【问题描述】:

我正在创建一个 Web 用户控件,用于在 AspxGridView 列上显示警报(删除/编辑)单击服务器端事件。 例如:

Deleted disabled on row then if As like asp grid view when delete command fire then on delete show message that delete is not allowed/confirm before delete as we in windows application..

原因:

To reduce the database hit for checking that  user allowed to delete/ Edit 
particular record.

I do not want to check thousand of rows to disable them OnHtmlRowCreated Event 
of AspxGridView

我从这个codeproject ajax enabled confirm box / messagebox 中得到了一个想法。 这里它使用 ajax 用户控件。它使用更新面板和 Molalpopupextender 控件来创建这个用户控件。

它提供了这些功能。

The MessageBox should have a simple usage. We should show the message with such a single line of code.
The MessageBox should be modal. I mean, a user should not be able to do any other operation while the message is open.
The MessageBox should support multiple messages. Multiple messages may be shown through one postback.
The MessageBox should have a different appearance according to the type of the message, whether it is an error message or just an information message.
The MessageBox should have confirmation functionality.
The MessageBox should be AJAX ready.

优点:此用户控件可以在服务器端调用,并且可以在 ajax 控件的服务器端功能上进行更新。

我不想在我的项目中包含 Ajax 库。所以我已经这样做了,我的解决方案如下:

Replaced Update Panel with CallbackPanel control
Replaced PopupExtender with DevExpress PopupControl
Add all content of the PopupExtender target panel's control to PopupControl content Collection

问题: DevExpress 控件没有 ajax 控件之类的 Update 方法,所有这些 callbackpanel 和 popupcontrol 都主要在 Callback 上工作。

这是用户控件的 PreRender 事件。在回发时更新用户控件的位置。我想在 gridview OnDeleting Event 上更新这个

受保护的覆盖无效 OnPreRender(EventArgs e) { base.OnPreRender(e);

        if (btnOK.Visible == false)
            mpeMsg.OkControlID = "btnD2";
        else
            mpeMsg.OkControlID = "btnOK";

        if (Messages.Count > 0)
        {
            btnOK.Focus();
            grvMsg.DataSource = Messages;
            grvMsg.DataBind();

            mpeMsg.Show();  /// Show AspxPopupControl like as like modalpopupExtender
            udpMsj.Update();  // I want to update CallbackPanel like this

        }
        else
        {
            grvMsg.DataBind();
            udpMsj.Update();  /// I want to update CallbackPanel like this
        }
        if (this.Parent.GetType() == typeof(UpdatePanel))
        {
            UpdatePanel containerUpdatepanel = this.Parent as UpdatePanel;

            containerUpdatepanel.Update();
        }
    }

还有另一种实现此功能的方法,例如在另一个页面上创建控件并将呈现的 html 加载到 弹出控件。但这也是 Callback 中的客户端功能。

我知道这些控件的回调功能,但我希望这个用户控件能够自动执行,因为 Ajax 控件与 Windows 控件一样, 但是在 DevExpress 中,无法使用提供服务器端功能的 DevExpress 控件来实现。

【问题讨论】:

    标签: c# asp.net user-controls devexpress


    【解决方案1】:

    利用http://www.devexpress.com/example=E1120 方法作为起点。此选项描述了如何为此目的使用 ASPxPopupControl(来自 DevExpress ASP.NET 产品线的弹出窗口)。

    我相信可以将所需的解决方案与 DevExpress 产品的使用结合起来。如果您有任何困难,请 DX 支持人员在这方面为您提供帮助。

    【讨论】:

    • 感谢您的建议@Mikhail .. 我很久以前就看过这个例子。我知道这件事。实际上,我想使用这些控件创建一个通用的用户控件,这些控件就像 ajax 控件一样工作。我不想使用任何技巧,所以我把这个问题放在这里。再次感谢。
    • 如果我按照示例进行操作,那么它只会在客户端工作。在示例中,用户控件是单独的实体,您将该用户控件放在 PopupControl 上。我在链接中指定了我想在 OnUpdating 事件中显示控制服务器端。简单来说,如果我初始化该控件,那么它将显示PopMessage/ConfirmBox。可以使用 Ajax 并正常工作。但我希望它通过“callbackPanel”和“PopupControl”.. 但所有这些都是在客户端启动的。 Popup.ShowOnPageLoad 不符合我的要求,因为您知道回调不会触发 preRender 事件..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-24
    • 1970-01-01
    • 1970-01-01
    • 2020-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多