Deferred Loading In ASP.NET

We were working on a problem where a user control is generating More than 5 MB of HTML and downloading this huge HTML in a browser results in a bad user experience. Then we decided to load this control, in another Asynchronous call, after loading the other content of the page.

There was a common method for this control that needs to be called to render this control i.e. GenerateControl().

Control was in an UpdatePanel, We put an ASP Timer control on the user control and Make it disabled, an overloaded GenerateControl() function i.e. GenerateControl(bool generate), now thi

s function will actually generate the HTML. And previous function GenerateControl() will only make the Timer enabled. Callback function Timer will call the GenerateControl(bool generate).

ASPX code


.CS code

void tickEvent(object sender,EventArgs e)
{
    GenerateControl(true);
}

private void GenerateControl(bool generate)
{
    //Generate HTML
    timer.Enabled = false;
}

private void GenerateControl()
{
    timer.Enabled = true;
}
zp8497586rq
Tags: , , , , ,

Comments are closed.