Is it possible to only load the data when the controls become visible, and not all when the page loads.
Thanks
Nick
1 Answer, 1 is accepted
0
Ivan Danchev
Telerik team
answered on 29 Aug 2025, 03:13 PM
Hi Nick,
You can load the data for the Carousel only after it becomes visible by using the Blazor component lifecycle methods. The recommended approach is to use the OnAfterRenderAsyncmethod, which lets you trigger data loading after all components on the page have finished rendering. This ensures that the data is loaded only when the Carousel is actually visible to the user.
Example: Load data after the Carousel is rendered
protectedoverrideasync Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
// Load data when the Carousel becomes visibleawait Task.Delay(500); // Optional delay if needed
CarouselData = await LoadCarouselDataAsync();
StateHasChanged(); // Update the UI with the loaded data
}
}