Stopping JavaScript graph drawing due to ASP.Net Asynchronous Postback

I have successfully developed a JavaScript graph that retrieves data from a GridView table and displays it on the page. However, I am facing an issue with a dropdown that asynchronously updates the table data when a different option is selected. After the async refresh, the JavaScript stops drawing the data, most likely because it runs before the updated table data is fully loaded.

Is there a way to ensure that the JavaScript executes after the async refresh? I have attempted placing the script in the <ContentTemplate> section of the UpdatePanel but have not seen any improvement.

<asp:UpdatePanel ID="upTeamSelect" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div class="form-grid">               
            <p>Team</p>
            <asp:DropDownList ID="cmbUser" cssclass="form-list" runat="server" AutoPostBack="True" DataSourceID="AP_Users" DataTextField="sr_userName" DataValueField="sr_usserName">
            </asp:DropDownList>

            <asp:SqlDataSource ID="AP_Team"  runat="server" ConnectionString="<%$ ConnectionStrings:<REDACTED>> %>" SelectCommand="SELECT [sr_userName] FROM [sr_users] WHERE ([sr_active] = @sr_active)" >
                <SelectParameters>
                    <asp:Parameter DefaultValue="TRUE" Name="sr_active" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="cmbTeam" EventName="SelectedIndexChanged" />
    </Triggers>
</asp:UpdatePanel>

<Script>
    <!-- Your custom JavaScript graph code goes here -->
</Script>

Answer №1

If you're looking to trigger actions after every page postback, whether it's an ajax or full postback, utilizing client-side page life-cycle events is the way to go.
One approach is using the page_loaded event like so:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

function pageLoaded(sender, args) {
    // Implement your graph data updates/initialization here
}

For a deeper dive into handling client-side events, refer to this resource.

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

Enhancing Grails dynamic dropdown to include a pre-selected value in edit.gsp

One feature I have implemented is a dynamic dropdown menu in my _form.gsp file that appears in both the create and edit pages. While it currently works as intended, I am seeking a way to display the selected value on the edit page. _form.gsp <g:s ...

Modify the publication directory (URL) of the publishing profile within the building process

In our ASP.Net solution, we have multiple projects, each with its own unique folder path specified in the build.pubxml file. For instance: In the Test project, the build.pubxml contains the following line: <publishUrl>C:\publish\Solution ...

insert a new empty row into an HTML table on the fly

I'm working with the code below and attempting to insert an empty row into a table whenever the date changes: <?php $old_date = $crew_rows[0]["date"] ?> <?php foreach ($crew_rows as $crew_row):?> <tr > <td style="text-align ...

Show the comment section only if the initial radio button is selected

I am struggling to implement a comment section that is displayed when the first radio button is checked. Here's the code I have tried: I attempted the following to show the section and test the associated script: <div id="commentaryDiv" ...

Stopping a countdown timer from refreshing in JavaScript

`<script type="text/javascript" src="jquery-1.6.2.min.js"></script> <h1 align="center" style="color:green">Creating a countdown timer using jQuery</h1> <h3 style="color:#FF0000" align="center"> You will be logged out in : &l ...

What is the best way to include the title "addmoves" to the server using AngularJS?

https://i.sstatic.net/yR2fk.png Furthermore, I am looking to include a button that allows users to add additional movies. The goal is to input multiple sets of data simultaneously, such as: newMovies = [ { movieName:"", director:"", release ...

Changing visibility when class is removed with display: none

I have a collection of div elements, some of them are currently hidden using the class "not-updated", while others are visible. .not-update{ display: none } With certain AJAX calls, some of these hidden divs may become visible by removing the ...

Deleting the chosen list item from an unordered list

I'm having some trouble removing the selected item with the class "selected" from my list using jQuery. Instead of just deleting the LI item, the entire list is getting cleared out. Here's a quick fiddle I created to demonstrate the issue: http ...

Event in javascript or jquery triggered whenever the value of a dropdown selection is altered

What options do I have when the user does not manually change a select value using JavaScript or jQuery events? For example, if I have multiple cascading selects and the user chooses a default value in one of them without triggering an event, how can I han ...

angular click triggers the following content

How can I make the following content appear when clicked? I have a list of content that displays up to 20 items, but I want to show the rest when clicked. I have created the nextMovieList method for this purpose. import { Component, OnInit } from ' ...

Ways to retrieve JSON data using Angular JS

I'm currently working on populating my table with data. The URL returns JSON data, but I'm struggling with how to retrieve it using AngularJS. Here is my services.js: angular.module('OrganisatieApp.services', []) .factory('organi ...

Cancel event for file uploads in Angular on Internet Explorer 11

We are currently facing an issue with file upload functionality in Internet Explorer 11 while using Angular 11. The problem lies specifically with the Cancel button of the file dialog box. <input #fileUploadCtrl class="form-control" type=" ...

Troubles arising while using ng serve in Angular 2

I'm currently facing an issue during the installation process of an existing Angular application. When trying to run the application using the ng serve command, I encounter the following error message: The "@angular/compiler-cli" package was not prope ...

How can one break down enum values in typescript?

I've defined an enum in TypeScript as shown below: export enum XMPPElementName { state = "state", presence = "presence", iq = "iq", unreadCount = "uc", otherUserUnreadCount = "ouc", sequenc ...

Tips for circumventing CORS in an ajax request using various browser extensions or add-ons

I am encountering a cross-origin problem with my WCF service. Despite adding an extension in chrome to bypass CORS, the issue persists. Is there any other extension/add-on/plugin available to test the service locally and bypass the CORS problem? Edit Aft ...

Tips for accessing the initial element of an array, storing it in a state, and sending it to a component

Is there a way to access and store the first object from the response data in a state? I attempted to achieve this by utilizing setData and assigning the first object of the data to it: export default function BuildingsDetail({buildingId}) { const [data ...

Exploring the Scope of React Functional Components

My current dilemma involves a React Functional Component acting as a video player. I'm facing an issue where I need to invoke a function named onEnded when the video player triggers its ended event. This function takes in two parameters: a callback pa ...

Issue with updating RadioButtonList within UpdatePanel

When a value is changed in a dropdownlist, I want to query a database and display the result in a radiobuttonlist. To AJAXify this process, I have included an UpdatePanel. However, after selecting a value in the dropdownlist, the radiobuttonlist does not r ...

Utilizing PHP to create an interactive website

As a novice PHP developer, I took to Google in search of tutorials on creating dynamic PHP websites. What I found was that many tutorials used the $_GET variable to manipulate URLs and make them appear like this: example.com/?page=home example.com/?page= ...

Create a discord.js bot that can randomly select and send a picture from a collection of images stored on my computer

I'm currently working on a bot that sends random pictures from an array of images stored on my computer. However, I encountered an issue when trying to embed the image, resulting in the following error message: C:\Users\47920\Desktop&bs ...