@typeparam TVal;
<SfCalendar TValue="TVal" @bind-Value="@CalValue">
</SfCalendar>
@code {
[Parameter]
public TVal CalValue { get; set; }
[Parameter]
public EventCallback<TVal> CalValueChanged { get; set; }
}
|
<TextBoxComponent TVal="DateTime?" @bind-CalValue="@value"></TextBoxComponent>
@code {
public DateTime? value { get; set; }
}
|
@using Microsoft.AspNetCore.Components
@using Syncfusion.Blazor.Calendars
<SfCalendar TValue="DateTime?">
</SfCalendar>
|
@model WebApplication1.Components.Pages.Person
@{
ViewData["Title"] = "Home Page";
}
<component type="typeof(WebApplication1.Components.Pages.Person)" render-mode="ServerPrerendered" />
@section scripts{
<script src="_framework/blazor.server.js"></script>
}
|
Hello,
Is this solution (about integrating Blazor components in razor pages) still valid and still the recommended implementation for the current .NET 7?
Thanks!
In .NET 7, you can use custom elements to integrate Blazor components into your Razor pages. Custom elements are a way to create your own HTML tags that can be used in HTML pages. You can use them to wrap your Blazor components and include them in your razor pages.
To create a custom element for your Blazor component, you can follow the steps outlined in the link you provided: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/?view=aspnetcore-7.0#blazor-custom-elements.
This tutorial provides guidance on creating and using custom elements in a Blazor app, including details on Razor syntax, component naming, namespaces, and component parameters
I think "custom elements" are for something else. i.e. "Use the custom element with any web framework. For example, the preceding my-counter custom HTML element that renders the app's Counter component is used in a React app with the following markup: <my-counter></my-counter>
What I'm looking for is the best/current/recommended way to integrate Blazor components in a standards server-side asp.net razor pages project.
Thank you
OK. Custom elements should work on razor pages too. I'll try this example: https://github.com/khalidabuhakmeh/BlazorCustomElementsSample
" The purpose of this repository is to show Blazor Custom Elements in action alongside ASP.NET Core Razor Pages. "
Hi Horacioj,
Thanks for the update.
Please get back to us if you need further assistance.
Regards,
Joshna L