Pages Html

NuGet packageOwin.Framework.Pages.Html
GitHub sourceOwinFramework.Pages.Html

Home |  Readme

[NeedsData] attribute | The OWIN Framework Pages

The [NeedsData] Attribute

Attach this attribute to a page element to specify that it has a dependency on some data. The framework will locate a suitable data provided and bind it to any page containing this page element.

Note that if many elements on the page depend on the same data, then the data provider will only be called once on the page and all of the page elements can bind to the same data.

Note that you can use regions to resolve data needs at the region level instead of at the page level allowing the same type of data to resolve to different records in different parts of the page.

You can also attach this [NeedsData] attribute to a data provider to create a heirachy of data providers that depend on each other. For example the data provider that provides a list of invoices can have a dependency on the data provider that provides customer data.

Example Usage

internal class AddressRegion { }

The [NeedsData()] attribute has the following properties you can set.


This allows you to define a dependency on a specific Data Provider using the name property of the data provider. If the data provider is in a different package then the name must be prefixed by the package namespace and a colon.


Defines a type of data that this element needs to be available at runtime when rendering the page. The framework will locate an appropriate Data Provider based on the other data needs and the Data Providers that are defined within the application.


This places additional constraits on the Data Provider selection. If there is a Data Provider that specified that is can supply this type of data in this scope then it will be selected. If there are no matching Data Providers, then Data Providers will be matched based on data type only.