Jayantha Lal Sirisena
Jayantha Lal Sirisena

Reputation: 21376

Render ASP.Net user controls parallel

Is it possible to render two user controls in aspx page in parallel. It seems like even though the data load is defined as async other user controls does not render while one user control is waiting for data to load.

I have a CustomGridView control which is inherited from System.Web.UI.WebControls.GridView . In my aspx page I have several CustomGridViews to be rendered . And also In my aspx page the page is defined as async=true ,

public class CustomGridView : GridView{
   //...
   protected override void OnPagePreLoad(object sender, EventArgs e)
   {
        Page.RegisterAsyncTask(new PageAsyncTask(GetDataAsync));
        base.OnPagePreLoad(sender, e);
   }
   private async Task GetDataAsync(){
       var data=await _service.GetDataAsync();
       this.DataSource=data;
       this.DataBind();
   }
    //...
 }

Upvotes: 1

Views: 287

Answers (1)

Paulo Morgado
Paulo Morgado

Reputation: 14856

I don't expect this to ever be possible as the rendering of ASP.NET WebForms controls might be dependent on the order of the rendering and where on the control tree they are.

However, that doesn't prevent the loading of all data sources in parallel before the rendering.

Upvotes: 1

Related Questions