# Allowing Load on Demand

Learn how you can allow the Web page to load on demand using Spread for ASP.NET. Also, learn how to specify properties to set the load on demand feature.

## Content

You can allow the Web page to load on demand -- as the user scrolls further down the spreadsheet the Spread component on the client loads another set of rows from the server as needed. The height of the component should be smaller than the height needed for the initial number of rows to load ([LoadInitRowCount](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.FpSpread.LoadInitRowCount.html) property); otherwise, the scroll bar will not be visible and you will need to use the next page icon instead of the scroll bar. The load on demand feature scrolls up to the maximum number of rows you have set with the page size. If the row count is greater than the page size, you will need to use the next page icon to display the rows beyond the page size setting.
The following properties are used to set the allow load on demand feature. They can be set at the control level or the sheet level.
FpSpread class:

* FpSpread.[AllowLoadOnDemand](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.FpSpread.AllowLoadOnDemand.html)
* FpSpread.[LoadInitRowCount](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.FpSpread.LoadInitRowCount.html)
* FpSpread.[LoadRowIncrement](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.FpSpread.LoadRowIncrement.html)

SheetView class:

* SheetView.[AllowLoadOnDemand](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.AllowLoadOnDemand.html)
* SheetView.[LoadInitRowCount](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadInitRowCount.html)
* SheetView.[LoadRowIncrement](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadRowIncrement.html)

You can specify whether to use the standard or background load on demand options with the [LoadOnDemandMode](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadOnDemandMode.html) property.
The load on demand feature is not intended to work with a hierarchical display (parent sheet expanding into child sheets) so it is disabled in a hierarchical Spread.

## Standard Load on Demand

The standard mode only loads the next set of rows if there are rows that are hidden from the view. The default value for the [LoadOnDemandMode](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadOnDemandMode.html) property is standard.

## Background Load on Demand

You can load new rows in the background before the last row is displayed. For example, if 20 rows are loaded and the user scrolls to row 15, the next set of rows is loaded. Set the [LoadOnDemandMode](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadOnDemandMode.html) property to Background to load the new rows before the last row is displayed. You can also specify whether to load the new rows using a time interval or when the scrolling is a specified number of rows from the bottom of the view. Use the [LoadOnDemandTriggerMode](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadOnDemandTriggerMode.html) property to specify whether to use a time interval or an offset from the bottom of the view.
The background load on demand allows other pending AJAX requests while rows are being loaded (rows are loaded without locking the Spread). The actions are put in a queue of pending requests to be processed later. When load on demand is finished, pending requests in the queue are processed until there are no more requests in the queue.

## Virtual Paging

Another option for loading pages as the user scrolls vertically is the [AllowVirtualScrollPaging](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.AllowVirtualScrollPaging.html) property. This can be used instead of the allow load on demand properties. The virtual paging feature will not work with load on demand. The [EnableClientScript](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.FpSpread.EnableClientScript.html) property must be true for the virtual paging. For the best performance, you may also wish to set [EnableAjaxCall](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.FpSpread.EnableAjaxCall.html) to true since the virtual paging uses Ajax calls.
The virtual scrolling option scrolls from the first row to the last row of the page size. If the row count is greater than the page size, then when you scroll past the maximum page size row, the next set of rows is loaded (a wait icon is displayed while the next page is loading in this case).
You can also display rows from the previous page with the [VirtualScrollPagingPrevRowCount](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.VirtualScrollPagingPrevRowCount.html) property.
The scroll bar button size reflects the total number of rows with virtual scrolling (rather than the number of currently loaded rows).

## Using the Properties Window

You can set several of the properties at design time using the Properties window of Visual Studio .NET or the Property grid in the designer.

1. Select the sheet.
2. Set the **AllowLoadOnDemand** property to true to allow loading on demand.
3. Set the **LoadInitRowCount** property to specify the initial number of rows to load.
4. Set the **LoadRowIncrement** property to specify how many rows to load after the initial set of rows is loaded.

## Using Code

Use the [AllowLoadOnDemand](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.AllowLoadOnDemand.html) property to allow load on demand. Set the [LoadInitRowCount](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadInitRowCount.html) property to load the initial set of rows. Set the [LoadRowIncrement](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.LoadRowIncrement.html) property to specify the number of rows to load after the initial page is loaded.

## Example

The height of the component should be smaller than the height of ten rows (for this example).

```csharp
FpSpread1.Sheets[0].RowCount = 40;
FpSpread1.Sheets[0].AllowLoadOnDemand = True;
FpSpread1.Sheets(0).PageSize = 40;
FpSpread1.Sheets[0].LoadInitRowCount = 10;
FpSpread1.Sheets[0].LoadRowIncrement = 10;
long i;
for (i = 1; i <= 20; i++)
{
FpSpread1.Sheets[0].Cells[i, 0].Value = i;
}
```

```vbnet
FpSpread1.Sheets(0).RowCount = 40
FpSpread1.Sheets(0).AllowLoadOnDemand = True
FpSpread1.Sheets(0).PageSize = 40
FpSpread1.Sheets(0).LoadInitRowCount = 10
FpSpread1.Sheets(0).LoadRowIncrement = 10
Dim i As Long
For i = 1 To 20
FpSpread1.Sheets(0).Cells(i, 0).Value = i
Next
```

## See Also

[VirtualScrollPagingPrevRowCount Property](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.VirtualScrollPagingPrevRowCount.html)
[ScrollingContentVisible Property](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.ScrollingContentVisible.html)
[VirtualScrollPagingFormatString Property](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.SheetView.VirtualScrollPagingFormatString.html)
[LoadOnDemandMode Enumeration](/spreadnet/api/latest/online-asp/FarPoint.Web.Spread/FarPoint.Web.Spread.LoadOnDemandMode.html)
[LoadRowsStart](/spreadnet/docs/latest/online-asp/overview/spweb-clientscriptref/clientscript-members/clientscript-allevents/CSSR-onLoadRowsStart)