Why is backend code being hit from control outside of Update Panel

Jim Powell 1 Reputation point
2022-08-11T18:53:32.55+00:00

I have an ASP.NET/C#/Javascript application that has a Master Page and numerous Child Pages. On one of the Child Pages, I have a Google Map that gets it data from the backend like this in the javascript code:

<script type="text/javascript">  
    async function InitializeMap() {  
                markersList = await JSON.parse('<%=ConvertDataTabletoString() %>');  

...
};

        <asp:Panel ID="pnGoogleMap" runat="server">  
            <div id="divGoogleMap" name="divGoogleMap" style="height: 600px; width: 100%; border: solid; border-color: white; border-width: 10px;" ></div>  
        </asp:Panel>  

        <asp:UpdatePanel ID="upCustomerInfo" ChildrenAsTriggers="false" runat="server" UpdateMode="Conditional">  
            <ContentTemplate>  
                <%-- Desktop version for spacing under map --%>  
                <asp:Panel ID="pnCustomerInfo" runat="server" style="display:none; border: solid; border-color: #00b2ee; border-width: 10px;" >  
                    <div style="height: 10px"></div>  
                    <button id="btnSaveCustomerInfo" type="button" title="Save" runat="server" onclick="return saveMapView();" class="button-green"><i class="material-icons">save</i></button>  
                    <button id="btnSaveCustomerInfoHelper" type="button" title="Save" runat="server" style="display:none;" onserverclick="btnSaveCustomerInfo_Click" />  

...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSaveCustomerInfo" runat="server" />
<asp:AsyncPostBackTrigger ControlID="btnSaveCustomerInfoHelper" runat="server" />
</Triggers>
</asp:UpdatePanel>

The Google Map is in it's own (non Update Panel) Panel and below it is an Update Panel that is populated with customer information when the user clicks on a pin on the map. When the user clicks the save button in the Update Panel to save customer changes, the "ConvertDataTableToString" method in the backend gets hit again even though it's not inside the Update Panel. I am not wanting to reload/render the map on the Partial Page update when saving customer information.

Though testing I was able to verify that the InitializeMap that contains the call to "ConvertDataTableToString" is NOT being executed on the Partial Page update, just the method itself is called.

I've not been able to figure out why that method is being called and how to prevent it from being called.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,253 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 55,686 Reputation points
    2022-08-12T16:07:15.853+00:00

    Update panel use ajax to do a form post. The server processes the post like any other postback (oninit, onload, etc) and click events are processed. The main difference, is rendering the response. As special response is built and the ajax caller knows how to update the dom with the special response.

    All the partial update logic is in the client, not the server.

    0 comments No comments