Wsu.Asis.AutoDisplay.Web
1.0.0.2
dotnet add package Wsu.Asis.AutoDisplay.Web --version 1.0.0.2
NuGet\Install-Package Wsu.Asis.AutoDisplay.Web -Version 1.0.0.2
<PackageReference Include="Wsu.Asis.AutoDisplay.Web" Version="1.0.0.2" />
<PackageVersion Include="Wsu.Asis.AutoDisplay.Web" Version="1.0.0.2" />
<PackageReference Include="Wsu.Asis.AutoDisplay.Web" />
paket add Wsu.Asis.AutoDisplay.Web --version 1.0.0.2
#r "nuget: Wsu.Asis.AutoDisplay.Web, 1.0.0.2"
#:package Wsu.Asis.AutoDisplay.Web@1.0.0.2
#addin nuget:?package=Wsu.Asis.AutoDisplay.Web&version=1.0.0.2
#tool nuget:?package=Wsu.Asis.AutoDisplay.Web&version=1.0.0.2
AutoDisplay.Web
This contains tools to automatically generate HTML tables and Description Lists.
For ASP.NET Core to pick up on the tag helpers, You need to add this to your _ViewImports.cshtml:
@addTagHelper *, AutoDisplay.Web
Tables
To generate a table, use the asp-for giving an IEnumerable<T> or a DataTable:
<table asp-for="MyList"></table>
The asp-for value is a ModelExpression, but it also can be used with non-model properties by
using an @:
<table asp-for="@myList.Where(i => i.Whatever)"></table>
Description Lists
Description lists will display the properties of an object or the key/value pairs in an
IDictionary:
<dl asp-for="Thing"></dl>
Like with tables, the asp-for value is a ModelExpression, but it also can be used with non-model
properties by using an @:
<dl asp-for="@things.First()"></dl>
This means it's possible to use foreach to display a list of objects for when there are too man
properties for a table or to make a list of items more mobile friendly:
<ul>
@foreach (var thing in this.Model.Things)
{
<li>
<dl asp-for="@thing"></dl>
</li>
}
</ul>
Links
Links can be created by using attributes that implement IAutoDisplayLinkGenerator and additional
route values can be added with attributes that implement IAutoDisplayRouteValueGenerator. A few
attributes are built in.
For IAutoDisplayLinkGenerator:
AutoDisplayUrlLinkAttributefor using a static URL base. This is passed tostring.Formatalong with the property value.[AutoDisplayUrlLink("https://example.com/{0}")] public int Id { get; set; }AutoDisplayPageLinkAttributefor generating links to razor pages. The name of the razor page route data parameter is also needed.[AutoDisplayPageLink("/Things/View", "ThingId")] public int Id { get; set; }
For IAutoDisplayRouteValueGenerator:
AutoDisplayStaticLinkRouteValueAttributefor providing a static value[AutoDisplayPageLink("/Things/ByStatus", "Status")] [AutoDisplayStaticLinkRouteValue("ResultsPerPage", "50")] public ThingStatus Status { get; set; }AutoDisplayPropertyLinkRouteValueAttributefor referencing another property in the same object to use as a route value[AutoDisplayPageLink("/Things/ByStatus", "Status")] [AutoDisplayPropertyLinkRouteValue("ResultsPerPage", nameof(ResultsPerPage))] public ThingStatus Status { get; set; } public int ResultsPerPage { get; set; }
CSS Classes
CSS classes can also be applied to the result container (<td> or dd) or to a generated link
using CssClassAttribute and LinkCssClassAttribute.
[AutoDisplayPageLink("/Things/View", "ThingId")]
[AutoDisplayLinkCssClass("linkClass")]
public int Id { get; set; }
[AutoDisplayCssClass("propertyClass")]
public string Name { get; set; }
Formatting Output
How the value and property names are displayed can be controlled with attributes.
By default, the name of the property will be used as the display name. This can be changed with a
DisplayAttribute:[Display(Name = "Thing ID")] public int ThingId { get; set; }Enums use the name by default, but the display value can also be set using a
DisplayAttribute:public enum MyOptions { [Display(Name = "Option 1")] Option1, [Display(Name = "Option 2")] Option2, [Display(Name = "Option 3")] Option3 }A
DataFormatAttributecan be used to specify formatting for the property. This get used withstring.Format.[DisplayFormat(DataFormatString = "{0:yyyyMMdd}")] public DateTime Created { get; set; }A
DataFormatAttributecan also be used to specify what to display when the value is null:[DisplayFormat(NullDisplayText = "None")] public int? Size { get; set; }A
DataTypeAttributecan also be used to change the format:[DataType(DataType.Currency)] public decimal Amount { get; set; } [DataType(DataType.EmailAddress)] public string? EmailAddress { get; set; }
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Wsu.Asis.AutoDisplay.Core (>= 1.0.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.