The functionality of closing the image on a model popup is not functioning properly following a postback

I am encountering an issue with my ajax modelpopup extender in my webform. The CancelControlID is set to an image called imgClose. When I click on imgClose after the popup has been displayed, it successfully closes the popup. However, if I click on any controls or select some controls that require a postback, clicking the image does nothing at all. Previously, I had a button set as the CancelControlID for the same modelpopup. It encountered the same issue, which I resolved by using the OnClick="btnClose_Click" codebehind method to hide the modelpopup.

For the imgClose, I attempted to use a client-side method, but it was unsuccessful. Any suggestions?

Below is my modelpopup extender, image control, and javascript:

<ajx:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnTest"
                BackgroundCssClass="modalBackground" PopupControlID="divPreview" DropShadow="true"
                CancelControlID="imgClose">


    <div runat="server" id="divPreview">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="testDesign" runat="server" CssClass="boxdesignCustomerPopUp" Width="600px" Height="200px">
                <div>
                    <table>
                        <tr>                                            
                            <td>
                                <center>
                                    <strong>
                                        <asp:Literal ID="PopupTitleBar" runat="server"></asp:Literal>
                                    </strong>
                                </center>
                            </td>
                            <td style="vertical-align: top; float: right; position: absolute; top: 0px; right: 0px;">                                                
                                <img id="imgClose" alt="Close" src="image/close-button-red.png" runat="server" onclick="closeModelPopup()" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div id="divMenu" style="float: left; width: 100px; height: auto">                                    
                </div>
                <div id="divBody" style="border: 2px">
                    <div id="divLedger" runat="server">
                        <hr />
                            <table>
                                <tr>
                                    <td class="designtextfont">Has Ledger</td>
                                    <td class="designtextbox">
                                        <asp:RadioButton ID="rdoLedgerYes" runat="server" AutoPostBack="True" GroupName="hasLedgerRdo"
                                                    Text="Yes" OnCheckedChanged="rdoLedgerYes_CheckedChanged" />
                                        <asp:RadioButton ID="rdoLedgerNo" runat="server" AutoPostBack="True" GroupName="hasLedgerRdo"
                                                    Text="No" OnCheckedChanged="rdoLedgerNo_CheckedChanged" />
                                    </td>
                                </tr>
                            </table>
                    </div>
                </div>
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>


<script type="text/javascript">
    function closeModelPopUp() {
        $find('ModalPopupExtender1').hide();           
    }
</script>

Answer №1

Consider relocating the imgClose button to the divPreview element outside of the UpdatePanel. Additionally, you can remove the onclick attribute from the imgClose button since the ModalPopupExtender handles it by configuring the CancelControlID property.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Generating a JSON Array Made up of JSON Elements Using JQuery

Currently, my goal is to send a JSON Object to the backend. Essentially, I aim to retrieve the input from 2 textfields and a list of all selected checkboxes. Below is an excerpt of my JavaScript code: function insertNewHero() { var selectedAbiliti ...

Error: The variable 'err' is undefined in the mongoose mongodb code

Every time I try to execute this code, an error pops up stating that err is undefined Below is the code snippet causing the issue: app.post('/tinder/cards', (req, res) => { const dbCard = req.body; Cards.create(dbCard, (err, data) => { ...

Error code 0xC00402C7: Email delivery failure

I am encountering an issue while trying to send a basic email using the code below: protected void email_Click(object sender, EventArgs e) { System.Net.Mail.MailMessage msgMail = new System.Net.Mail.MailMessage(); msgMail.From = new System.N ...

Displaying React components using Bootstrap in the navigation bar

I'm feeling a little stuck here. I'm currently working with React Bootstrap and the Navigation component. One of the routes in my application is the dashboard, which is only accessible after logging in. When a user navigates to the dashboard, I ...

jquery token selection dropdown box

I am not encountering any errors with this particular issue, however upon reviewing the plugin it appears that it should only toggle "admin admin" in the dropdown list. I am currently utilizing the most recent version of jquery. Upon further investigation ...

Dynamic font sizing in CSS allows text on a webpage to

I am working on creating a dynamic screen using AngularJS. Within this screen, there are objects with a specific size: .item { margin: auto; margin-bottom: 10px; width: 11vw; height: 11vw; text-overflow: ellipsis; overflow: hidden; } These i ...

Creating a Page with Python Selenium for JavaScript Rendering

When using Python Splinter Selenium (Chromedriver) to scrape a webpage, I encountered an issue with parsing a table that was created with JavaScript. Despite attempting to parse it with Beautiful Soup, the table does not appear in the parsed data. I am str ...

How to temporarily toggle an event on and off using jQuery

Is there a way to control the activation and deactivation of a jQuery event? I currently have this functioning code that runs when the page is ready: $(".panzoom").panzoom({ $zoomIn: $(".zoom-in"), $zoomOut: $(".zoom-out"), $zoomRange: $(".zoo ...

Unsynchronized state of affairs in the context of Angular navigation

Within my Angular project, I am currently relying on an asynchronous function called foo(): Promise<boolean>. Depending on the result of this function, I need to decide whether to display component Foo or Bar. Considering my specific need, what woul ...

Troubleshooting CSS appendChild not functioning as anticipated

I'm attempting to manually input CSS for font-face in a new window with the following code: const css = '@font-face {font-family:Roboto; src:url("assets/fonts/Roboto-Black.ttf");}'; const head = this.externalWindow.document.getElementsByTag ...

The AngularJS ngModel directive encounters issues when used within a ui-bootstrap tabset

Check out the code snippet below to see the issue at hand: <!DOCTYPE html> <html ng-app="plunker"> <head> <title>AngularJS Plunker</title> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/cs ...

`AJAX jQuery for efficient file uploads`

I am struggling to upload a file input using jQuery ajax without causing the page to refresh. Here is my HTML form: <form name="uploadform" id="uploadform" method="post" enctype="multipart/form-data"> <div name="profileBiodata" id="profileBioda ...

Access the Express server by connecting to its IP address

Is it feasible to connect to an express server using the server's UP address? If so, how would one go about doing this? (Examples of code snippets would be greatly appreciated) ...

Retrieving Text Between HTML Tags Using jQuery

Disclosure: I am fully aware of the messy HTML code in this legacy application. Unfortunately, due to its extensive dependencies, making any changes to the HTML structure is not feasible. Despite the circumstances, here is the code snippet at hand: <t ...

Why isn't the <embed> resource loading in Chrome when $(document).ready() is triggered?

When $(document ).ready() is called in Firefox and IE, the SVG <embed> document is retrieved. However, in Chrome, the getSVGDocument returns null at this moment. (Although it seems to find it approximately 7ms later, as demonstrated by the setTimeou ...

Using Jquery Ajax in Conjunction with Spring MVC

I recently encountered an issue while trying to make an ajax query from a Spring MVC JSP page. The request was successfully made and I could see the JSON response on the browser. $.get("${pageContext.request.contextPath}/xxx.htm", {x: y}, function(result) ...

When using Node.js and geth together, running JavaScript code may lead to the creation of zombie processes, causing the

Currently, I am utilizing a JavaScript code that connects to the web3 package on Ethereum's JSON RPC API. This code is designed to iterate through each transaction in an incoming block. If the transaction involves an internal wallet, it sends the rele ...

Using jQuery to prepend elements and then fade them in

Whenever a user makes a post, it should be displayed at the top of the feed page with a nice fadeIn effect. However, my current script seems to hide all the updates before showing them again. I only want this effect to apply to the latest status. What cou ...

The application seems to be experiencing issues following the Chrome update to version 66, yet it continues to function properly in

link to error message2 days back Google Chrome automatically updated to version 66. Once this update occurred, my website, which was previously running smoothly, stopped functioning properly in Google Chrome but continued to work without any issues in Fire ...

Choosing different data clusters in a database

I am encountering an issue with an online quiz that generates random questions. The problem is that it tends to repeat previous questions. I have a limited set of questions - a total of 10 in my database - but I am restricting the output to just 5 random q ...