Reputation: 73731
I use UpdatePanels in a ModalPopupExtender and it works well (allowing parts of the dialog box to be refreshed when some controls are clicked, while avoiding full postbacks), but there is one small thing that is not exactly what I would like.
The OK button is disabled by default and enabled when changes are made in the dialog box, so the button is in an UpdatePanel. However, I would like a click on the OK button to cause a full postback. Is there a "natural" way to achieve that behavior?
N.B. Avoiding full postbacks is not only a matter of esthetics: they cause the dialog box to disappear from the screen.
Upvotes: 1
Views: 672
Reputation: 32693
If the dialog disappears from the screen, just make it appear again when the full postback completes.
if(DialogShouldBeVisible)
{
mpe.Show();
}
Anyways, to cause a full postback you just register it as a regular PostBackTrigger
instead of AsyncPostBackTrigger
.
<asp:UpdatePanel runat="server">
<Triggers>
<PostBackTrigger ControlId="OkBtn">
</Triggers>
<ContentTemplate>
<asp:Button runat="server" id="OkBtn" />
</ContentTemplate>
</asp:UpdatePanel>
By the way, I recommend against using UpdatePanel and ModalPopupExtender and anything else from the Ajax Control Toolkit. They don't fit in well with other easily customizable client side stuff. Instead, use dialog from jQuery UI or Bootstrap or some other well supported client side framework, and use AJAX to pass data to the server. It's much easier to put together a nice site that way.
Upvotes: 1