ASP.NET Core Controls - .NET Core 3 Support and Visual Studio Enhancements (v19.2)

ASP.NET Team Blog
14 November 2019

In this post, I'll discuss a couple of major enhancements to the DevExtreme ASP.NET Core and MVC Components in the latest v19.2 release.

.NET Core 3 Support

Without a doubt, .NET Core 3 is a major release that offers several cross-platform advantages over previous versions.

With the v19.2 release, I'm happy to announce support for .NET Core 3 within our ASP.NET Core product line, and this includes DevExtreme-based controls, Office-inspired controls, and Reporting.

Documentation

You can test-drive how our components use .NET Core 3 with the following documentation articles:

Visual Studio Enhancements

Form Scaffolding

Our Visual Studio Scaffolding wizard can now generate DevExtreme-based Forms from models or DTO classes.

For example, if you have a C# class that looks like this:

public class OrderDTO {
    public int ID { get; set; }

    public DateTime? ShippedDate { get; set; }

    [Required]
    public string ShipCity { get; set; }

    [Required]
    public string ShipAddress { get; set; }
}

Then our scaffolding wizard will create the following Razor markup:

@(Html.DevExtreme().Form<OrderDTO>()
    .Items(items => {
        items.AddSimpleFor(m => m.ID);
        items.AddSimpleFor(m => m.ShippedDate);
        items.AddSimpleFor(m => m.ShipCity);
        items.AddSimpleFor(m => m.ShipAddress);
    })
)

Which, at runtime, will render a fully-functional Form component, with the relevant editors powered by DevExtreme widgets:

ASP.NET Core Form Component

The scaffolding wizard will also generate the necessary form validation. For example, in that image of the generated form, notice how the editors that correspond to the fields annotated with the [Required] attribute in the C# class have been marked to require input.

Besides validation, the Form also recognizes the [Display] attribute. You can use it for labels, watermarks, and description lines. Here's how it works: if I decorate the FirstName property as shown below:

[Display(
    Name = "First name",
    Prompt = "Enter your first name...",
    Description = "As it appears on your passport or identification.")]
public string FirstName { get; set; }

Then it will render:

The Settings tab of the scaffolding wizard allows you to choose individual properties and customize form settings, such as column count or label location:

The new scaffolding wizard for the Form component will save you time and help you create forms for your web applications. We also provide scaffolding for the DataGrid and TreeList components.

Async API Controllers

Asynchronous programming, with the addition of the async/await keywords, was a welcome addition to the C# language. With this release, our scaffolder also supports async/await in API Controllers. Controllers generated by our API Controller Scaffolding Wizard are asynchronous by default. This means the controller actions are non-blocking and take advantage of the asynchronous capabilities of Entity Framework Core.

[HttpGet]
public async Task<IActionResult> Get(DataSourceLoadOptions loadOptions) {
    var products = _context.Products.Select(i => new {
        i.ProductId,
        i.ProductName,
        i.UnitPrice
    });
    return Json(await DataSourceLoader.LoadAsync(products, loadOptions));
}

ASP.NET MVC Scaffolding

As you may know, we offer two major libraries that support Microsoft's ASP.NET MVC framework. Our ASP.NET MVC controls based on DevExtreme also get the same scaffolder enhancements mentioned above.

Test It Today

Download the v19.2 update to test these new capabilities with our ASP.NET Core products today.

Then be sure to let us know your feedback. Thanks in advance!

1 comment(s)
Fabrizio Canevali
Fabrizio Canevali
Great !
14 November, 2019

Please login or register to post comments.