Search code examples
c#asp.netajaxcontroltoolkitmodalpopupextender

Conditionally display a ModalPopupExtender AJAX


I know you can utilize a ModalPopupExtender and have it be displayed when the user clicks a button or something of the sort by assigning the TargetControlID. What I'm looking to do is display this popup when an error occurs on my page. So by using conditional logic in the C# side of things, for example, if a certain variable is set to something, display this popup. Is there a way I can do this, or something similar?


Solution

  • Yep, in your C# code you can call

    my_ModalPopupExtender.Show();
    

    Where my_ModalPopupExtender is the name of your popup extender.

    It's that easy!