0

I have an Ajax ModalPopUpExtender which works fine when launched by the target control, but what I want to do is launch it from a server side Button_Click event in VB.

This is because I want to check some variables before launching the ModalPopUpExtender.

I have tried the .show method which works fine on an initial PageLoad event when there is no post back, but the method won't work from an asp:button's onclick event or from a post back event.

I have given the ModalPopUpExtender a dummy button to target as you can't run one without the TargetControlID being set. The dummy control is visible.

As the .show method works on a PageLoad event I know the ModalPopUpExtender is set up correctly, but what could be stopping it from running from a server-side event?

Here's my code:

<ajax:ModalPopupExtender
ID="mp1"
runat="server"
PopupControlID="Panel1"
TargetControlID="btnShowPopUp"                                                                      CancelControlID="btnClose"
BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
Sub btnShow_Click(ByVal sender As Object, ByVal e As EventArgs)

        if myVariable = 1 then

           mp1.show

        End if

End Sub
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
russell
  • 23
  • 1
  • 7
  • 1
    Thanks to Visual Vincent for sorting the format of my question - I'm not a regular poster here so detail on the correct etiquette isn't my forte! Vincent, feel free to correct my answer too! – russell Dec 09 '17 at 15:25

1 Answers1

1

After searching on more permutations of my question I finally found the answer in an existing answer on the site. The target control has to be a hidden field object, not another button.

The full answer is at:

ASP.NET: ModalPopupExtender prevents button click event from firing

russell
  • 23
  • 1
  • 7