【发布时间】: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