C# – DevExpress Web User Control – Create MessageBox, ConfirmBox

asp.netcdevexpressuser-controls

I am creating a web user control for showing Alert on AspxGridView Columns(Delete/Edit) click on Server side events.
For example:

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

Reason:

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

I have taken an idea from this codeproject ajax enabled confirm box / messagebox.
Here it is using ajax user controls. It is using Update Panel and Molalpopupextender control to create this user control.

It provides these features.

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.

Pros: This user control can be called at server side and can be updated on server side functions of the ajax controls.

I do not want to include Ajax library in my project. so that i have done to use this my solution as follows:

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

Problem:
DevExpress Control do not have Update method like ajax controls and all of these callbackpanel and popupcontrol works on Callback mostly.

This is User Control's PreRender Event. Where user control is updated on postback. I want to update this on gridview OnDeleting Event

protected override void 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();
        }
    }

There are another way to implement this functionality like create controls on another page and load rendered html to the
popupcontrol. but this is alos client side functionality in Callback.

I know the callback functionality with these controls but I want this usercontrol to automate itsself as Ajax control do same as windows controls,
but in DevExpress there is not way to implement using DevExpress controls that provide server side functionality.

Best Answer

Utilize the http://www.devexpress.com/example=E1120 approach as a starting point. This option describes how to use the ASPxPopupControl (a popup window from DevExpress ASP.NET product line) for this purpose.

I believe it is possible to combine the required solution with the use of DevExpress products. If you have any difficulties, ask DX support guys to help you in this regard.

Related Topic