Skip to content
Advertisement

asp modal popup closes immediately when running it from user control

I have a user control that contains a confirm button extender and a modal popup extender. It looks like:

JavaScript

The user control gets a dropdownlist. When changing the dropdownlist selection, the button onclick event should run. In the user control aspx.cs there is the follow code:

JavaScript

Use the user control in aspx looks like:

JavaScript

and in aspx.cs:

JavaScript

This is working fine, almost… The problem is that when changing the dropdownlist selection, the popup modal extender opens, but closes immediately. What can be the issue?

Thanks!

Advertisement

Answer

When selected item changes, your javascript code is trying to click on btnConfirmSelection button. The problem is, you have AutoPostBack="true". So it is posting back the page at the same time. For that reason it looks like the modal is closing down as you get the page again from server.

I haven’t tested your code but I’d suggest to set AutoPostBack="false" and check if that fixes the problem.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement