Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5973441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:48:02+00:00 2026-05-22T20:48:02+00:00

How do I prevent my asp:ModalPopupExtender from closing after or during a postback to

  • 0

How do I prevent my asp:ModalPopupExtender from closing after or during a postback to the server??

Here is my code:

JAVASCRIPT

// Confirm popup Ok button
function OnOk() {
    $('#confirmPopup').hide();
    ClickSaveButton();      // does a postback
    ShowGridPopup();
}

ASP.NET AJAX

    <asp:ModalPopupExtender BehaviorID="confirmPopup" ID="confirmPopup" runat="server"
        TargetControlID="butConfirm" PopupControlID="ConfirmView" BackgroundCssClass="modalBackground"
        OnOkScript="OnOk();" OnCancelScript="OnCancel();"
        OkControlID="yesButton" CancelControlID="noButton">
    </asp:ModalPopupExtender>

No matter if I call ShowGridPopup() before or after the postback method ClickSaveButton(), the popup still dissapears. How can I prevent this?

EDIT

Here is the code for the ShowGridPopup() and ClickSaveButton()

function ShowGridPopup() {
    if (getID() == "Popup1") {
        ShowGridPopup1();
    } else if (getID() == "Popup2") {
        ShowGridPopup2();
    }
}

function ClickSaveButton() {
    var _id = $('a[id$="butSave"]').attr("ID");
    __doPostBack(_id.replace("_", "$"), '');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:48:03+00:00Added an answer on May 22, 2026 at 8:48 pm

    I have found a way to by pass this, here is my solution: You have to create a new HiddenField controller from the server-side in ASP that will be used to store the ID of the ModalPopupExtender that you want to show after postback, it is set to null if there is no popup to be shown.

    <!-- Grid Popup ID: to obtain the grid popup ID from server-side -->
    <asp:HiddenField id="gridPopupID" runat="server" value="" />
    

    Next, we need to set the ID to the HiddenField before we use the save event

    // Confirm popup Ok button
    function OnOk() {
        $('#confirmPopup').hide();                          // hides the current confirmation popup
        $("#<%= gridPopupID.ClientID %>").val(getID());     // set the ID to the hiddenField.
        ClickSaveButton();                                  // simulates the click of the save button
    }
    

    Now, in the code behind, all we need to do is check the value of the HiddenField text field and we can just do a .Show() on the correct popup accordingly.

    Protected Sub OnSaveAssociation(ByVal sender As Object, ByVal e As EventArgs) Handles butSaveAssociation.Click
    
    ' ommited code: save changes to back end
    
                ' determine which popup to show
                Dim _id As String = gridPopupID.Value
                Select Case _id
                    Case "Popup1"
                        gridPopup1.Show()
                        gridPopupID.Value = Nothing
                    Case "Popup2"
                        gridPopup2.Show()
                        gridPopupID.Value = Nothing
                End Select
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to prevent Session.Timeout extension on certain event from codebehind? <asp:Timer ID=Timer7 runat=server Interval=540000
Is there a way prevent an ASP gridview from always relying on javascript for
I've pieced together some code to use in ASP.NET to prevent controls from losing
I am using an ASP.NET ModalPopupExtender on a page and would like to prevent
I want to prevent my asp.net / c# 2008 web pages from being cached
Is it possible to prevent an asp.net Hyperlink control from linking, i.e. so that
I need to check all of my asp code to prevent SQL injection. Should
I am working on a ASP.NET application. I want to prevent the user from
How can I prevent my asp.net 3.5 website from being screen scraped by my
I am building onto the example found here: http://www.mikesdotnetting.com/Article/126/ASP.NET-MVC-Prevent-Image-Leeching-with-a-Custom-RouteHandler What I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.