Can't Get Syncfusion Blazor Components Working In Razor Pages?
I'm working in a new ASP.NET Core 3.1 With Razor Pages application (as opposed to the pure Blazor app template default) and I want to use Syncfusion Blazor components in it but I'm having trouble getting it to work. I've followed the instructions on numerous sites about how to enable Blazor components in an MVC based application that uses Razor pages (changing the Configure and ConfigureServices methods in startup.cs, adding the endpoint, including the .js for Blazor, etc.).
If I write a component myself and use that it seems to work just fine so it appears that Blazor is indeed working as expected. But I tried using Syncfusion's Blazor library and it just refuses to work. I've tried things in the Razor page like:
@(await Html.RenderComponentAsync<Syncfusion.EJ2.Blazor.Calendars.EjsDateTimePicker>(RenderMode.ServerPrerendered))which works just fine for my manually created Blazor component but not the third party EjsDateTimePicker component. I've also made sure to include the @using references that are needed and VS finds everything, as well as including the JS references to ej2.min.js and ej2.interop.min.js in my layout file.
I also tried including the third party component into my manually created component since Blazor allows for that and VS recognizes the component/tag but still refuses to render it. In that case, when I call my own component like:
<CustomRazorTest>@(await Html.RenderComponentAsync<TestProj.Components.Pages.CustomRazorTest>(RenderMode.ServerPrerendered))CustomRazorTest>
it renders everything except the Syncfusion EjsDateTimePickercomponent. I also tried the different rendering methods just in case that might fix it. But nothing seems to work.- Install the Syncfusion.EJ2.Blazor Nuget package in your application by right clicking on the project and select Manage Nuget Packages.
- Search for Syncfusion.EJ2.Blazor package and install them.
- Open _Imports.razor file and import Syncfusion.EJ2.Blazor.
|
@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Calendars
|
- Add the script and style files in Pages/Shared/_Layout.cshtml file.
|
|
- Add the Syncfusion Blazor DatePicker component in Pages/Counter.razor file
|
<EjsDatePicker Placeholder='Choose a Date'></EjsDatePicker>
|
|
Visual Studio Version |
Version 16.4.0 Preview 6.0 |
|
Syncfusion Blazor Nuget version |
17.3.0.29-beta |
|
Syncfusion Asp.Net Core Nuget version |
17.3.0.31 |
|
.NET Core version |
.NET Core 3.1 |
|
.NET Core SDK version |
.NET Core 3.1 Preview 3 |
2. After proper declaration of blazor.server.js, I needed the following code to get events working correctly or else things like button clicks wouldn't register. It must be placed AFTER the blazor.server.js above:
- 6 Replies
- 3 Participants
-
RT Ryan Turcotte
- Dec 4, 2019 08:48 PM UTC
- Dec 11, 2019 09:18 AM UTC