I\'m using Microsoft AjaxControlToolkit for modal popup window.
And on a modal popup window, when a postback occurred, the window was closing. How do I prevent from
Was having this same problem keeping a modal open during postbacks.
My solution:
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.
In the load event for the page control containing the modal. Determine if the postback is from a child of mine. Determine if it is from the control that is in the modal panel.
Protected Sub Control_Load(sende As Object, e As EventArgs) Handles Me.Load
If IsPostBack Then
Dim eventTarget As String = Page.Request.Params.Get("__EventTarget")
Dim eventArgs As String = Page.Request.Params.Get("__EventArgument")
If Not String.IsNullOrEmpty(eventTarget) AndAlso eventTarget.StartsWith(Me.UniqueID) Then
If eventTarget.Contains("$" + _credentialBuilder.ID + "$") Then
' Postback from credential builder modal. Keep it open.
showCredentialBuilder = True
End If
End If
End If
End Sub
In prerender check my flag and manually show the modal
Protected Sub Control_PreRender(ByVal sende As Object, ByVal e As EventArgs) Handles Me.PreRender
If showCredentialBuilder Then
_mpeCredentialEditor.Show()
End If
End Sub