<p>I'm using Microsoft AjaxControlToolkit for modal popup window.</p>

<p>And on a modal popup window, when a postback occurred, the window was closing. How do I prevent from the closing action of the modal popup?</p>

[{'answer_id': 41910, 'author': 'Ricky Supit', 'author_id': 4191, 'author_profile': 'https://Stackoverflow.com/users/4191', 'pm_score': 3, 'selected': False, 'text': '<p>You can call <code>Show()</code> method during postback to prevent the modal popup window from closing</p>\n\n<pre><code>MyModalPopoupExtender.Show()\n</code></pre>\n'}, {'answer_id': 42188, 'author': 'Jon Erickson', 'author_id': 1950, 'author_profile': 'https://Stackoverflow.com/users/1950', 'pm_score': 2, 'selected': False, 'text': '<pre><code>protected void Page_Load(object sender, EventArgs e)\n{\n    if (Page.IsPostBack)\n    {\n        // reshow\n        MyModalPopup.Show()\n    }\n}\n</code></pre>\n'}, {'answer_id': 42798, 'author': 'Ali Ersöz', 'author_id': 4215, 'author_profile': 'https://Stackoverflow.com/users/4215', 'pm_score': 2, 'selected': False, 'text': "<p>I guess that works but not in my case. I've a user control that opened in a modal popup and this user control makes postback itself. So in that user control I've no modal popup property.</p>\n\n<p>I guess, I've to create an event for my user control, and the page that opens the modal popup have to reopen it in this event.</p>\n"}, {'answer_id': 542842, 'author': 'ForceMagic', 'author_id': 62921, 'author_profile': 'https://Stackoverflow.com/users/62921', 'pm_score': 1, 'selected': False, 'text': "<p>Like you prolly already know, the modal popup is clientside only, yeah you can gather informations in it during the postback, but if you do a postback he will hide 100% of the time. </p>\n\n<p>Of course, like other proposed, you can do a .show during the postback, but it depends on what you need to do.</p>\n\n<p>Actually, I don't know why you need a postback, if it's for some validations try to do them clientside.</p>\n\n<p>Could you tell us why you need to do a postback, maybe we could help you better ! :)</p>\n"}, {'answer_id': 4292954, 'author': 'JuanKo', 'author_id': 522419, 'author_profile': 'https://Stackoverflow.com/users/522419', 'pm_score': 1, 'selected': False, 'text': "<p>Following previous case... </p>\n\n<p>In Simple.aspx, user has to enter the name of a company. If user don't remember name of the company, he can click a button which will open a pop up modal window.</p>\n\n<p>what I want to do in the modal window is permit the user to do a search of a list of companies. He can enter a partial name and click search. Matches will be shown in a list below. He can click in an item of the list and return. If company does not exist, he can click a button 'New' to create a new company.</p>\n\n<p>So, as you can see, I want a lot of functionality in this modal window.  </p>\n\n<p>Thanks!</p>\n\n<p>JC</p>\n"}, {'answer_id': 8576317, 'author': 'Gregor Primar', 'author_id': 1107945, 'author_profile': 'https://Stackoverflow.com/users/1107945', 'pm_score': 4, 'selected': False, 'text': '<p>Put you controls inside the update panel. Please see my sample code, pnlControls is control that holds controls that will be displayed on popup:</p>\n\n<pre><code>&lt;asp:Panel ID="pnlControls" runat="server"&gt;\n\n    &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;\n        &lt;ContentTemplate&gt;\n               &lt;asp:Button ID="TestButton" runat="server" Text="Test Button" onclick="TestButton_Click" /&gt;\n            &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;         \n        &lt;/ContentTemplate&gt;\n\n    &lt;/asp:UpdatePanel&gt;\n</code></pre>\n\n<p></p>\n\n<p>This will do the job for you :)</p>\n\n<p>Best regards,\nGregor Primar</p>\n'}, {'answer_id': 27068727, 'author': 'Darrel Lee', 'author_id': 307968, 'author_profile': 'https://Stackoverflow.com/users/307968', 'pm_score': 2, 'selected': False, 'text': '<p>Was having this same problem keeping a modal open during postbacks.</p>\n\n<p>My solution:</p>\n\n<p>Use EventTarget to determine if the postback is coming from a control in the modal and keep the model open if it is.   The postback can come from a control in the modal iff the modal is open.</p>\n\n<p>In the load event for the page control containing the modal.  Determine if the postback is from\na child of mine.  Determine if it is from the control that is in the modal panel.</p>\n\n<pre><code>    Protected Sub Control_Load(sende As Object, e As EventArgs) Handles Me.Load\n        If IsPostBack Then\n            Dim eventTarget As String = Page.Request.Params.Get("__EventTarget")\n            Dim eventArgs As String = Page.Request.Params.Get("__EventArgument")\n\n            If Not String.IsNullOrEmpty(eventTarget) AndAlso eventTarget.StartsWith(Me.UniqueID) Then\n                If eventTarget.Contains("$" + _credentialBuilder.ID + "$") Then\n                    \' Postback from credential builder modal.  Keep it open.\n                    showCredentialBuilder = True\n                End If\n            End If\n        End If\n    End Sub\n</code></pre>\n\n<p>In prerender check my flag and manually show the modal</p>\n\n<pre><code>    Protected Sub Control_PreRender(ByVal sende As Object, ByVal e As EventArgs) Handles Me.PreRender\n        If showCredentialBuilder Then\n            _mpeCredentialEditor.Show()\n        End If\n    End Sub\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/41824', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4215/']