Using ConfirmButtonExtender with ModalPopup Extender

Today at work, an end user came and ask me that delete button simply deletes the row from the grid and does not give me a confirmation dialog. Can you fix this? I said sure. I simply had to add button extender to my grid view and I can then display the alert popup as soon as user clicks delete button. But obviously the alert box that comes up is pretty boring and there is not much you can do to spice it up. Than after researching a little bit, I realized that I could actually extend my button control extender with modal popup control extender. Button Control Extender has an additional property called displaymodalpopupid where you can reference the id of the modal popup extender. After that I simply added a modal popup extender and specify the targetcontrolid to be the delete button and popup control id to be the panel that will displayed. Here is the markup that creates a customized confirm dialog box.

image

In the above code, I am setting the target control id to be the delete button and displaymodalpopupid to be the modalpopupextender. In the ModalPopup extender, I set the cancel and ok control that will close and cancel the popup. Furthermore my target control id for the ModalPopup extender is still the button control. Here is how the page looks like.

image

4 Comments

  • Thanks for your explanation, it works. But is it a good idea to put the popup panel in the itemtemplate ? Cause if we have a lot of rows, we'll have as many popup as we have rows so it can lead to a important weight for this page. I think putting the popup outside the gridview is a better way to reduce loading time.

  • same question as Aurél.

  • Nice but i have question
    how we can change the content on click of linkbutton?

  • Hello,

    Maybe you feel like helping me solve a mystery?
    If so, check out the details here:

    http://forums.asp.net/t/1712651.aspx/1?ConfirmButtonExtender+not+working+after+adding+an+unrelated+modal+popup

    Thanks for any help. Have a good day.

Comments have been disabled for this content.