Skip to content

Commit

Permalink
Update .NET 8.0 Blazor web app EF Core (dotnet#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymsodev authored Nov 14, 2023
1 parent 8a1bb70 commit 5207579
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion 8.0/BlazorWebAppEFCore/Components/Pages/AddContact.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/add"
@attribute [RenderModeServer]
@rendermode InteractiveServer
@using BlazorWebAppEFCore.Grid
@inject IDbContextFactory<ContactContext> DbFactory
@inject NavigationManager Navigation
Expand Down
11 changes: 6 additions & 5 deletions 8.0/BlazorWebAppEFCore/Components/Pages/EditContact.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/edit/{ContactId:int}"
@attribute [RenderModeServer]
@rendermode InteractiveServer
@using Microsoft.EntityFrameworkCore;
@using BlazorWebAppEFCore.Grid
@using BlazorWebAppEFCore.Data
Expand All @@ -15,10 +15,11 @@
}
else
{
<ContactForm Busy="@Busy" Contact="@Contact"
DbContact="@DbContact"
IsAdd="false"
CancelRequest="Cancel"
<ContactForm Busy="@Busy"
Contact="@Contact"
DbContact="@DbContact"
IsAdd="false"
CancelRequest="Cancel"
ValidationResult="@(async (success) => await ValidationResultAsync(success))" />
}
@if (ConcurrencyError)
Expand Down
2 changes: 1 addition & 1 deletion 8.0/BlazorWebAppEFCore/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@page "/"
@page "/{Page:int}"
@attribute [RenderModeServer]
@rendermode InteractiveServer
@using BlazorWebAppEFCore.Grid
@using Microsoft.EntityFrameworkCore
@inject IContactFilters Filters
Expand Down
6 changes: 4 additions & 2 deletions 8.0/BlazorWebAppEFCore/Components/Pages/ViewContact.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/View/{ContactId:int}"
@attribute [RenderModeServer]
@rendermode InteractiveServer
@using BlazorWebAppEFCore.Grid
@using BlazorWebAppEFCore.Data
@using Microsoft.EntityFrameworkCore
Expand Down Expand Up @@ -40,7 +40,9 @@ else
</a>
@if (!Deleted)
{
<a class="btn btn-primary" href="edit/@Contact.Id" title="Edit">Edit</a><span>&nbsp;</span>
<a class="btn btn-primary" href="edit/@Contact.Id" title="Edit">Edit</a>

<span>&nbsp;</span>
@if (!ShowConfirmation)
{
<button class="btn btn-danger" @onclick="@(() => { ShowConfirmation = true; EditSuccess = false; })">Delete</button>
Expand Down
1 change: 1 addition & 0 deletions 8.0/BlazorWebAppEFCore/Components/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
@using Microsoft.EntityFrameworkCore
@using BlazorWebAppEFCore.Data
@using BlazorWebAppEFCore.Grid
@using static Microsoft.AspNetCore.Components.Web.RenderMode
5 changes: 3 additions & 2 deletions 8.0/BlazorWebAppEFCore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorComponents()
.AddServerComponents();
.AddInteractiveServerComponents();

// Register factory and configure the options
#region snippet1
Expand Down Expand Up @@ -47,8 +47,9 @@
app.UseHttpsRedirection();

app.UseStaticFiles();
app.UseAntiforgery();

app.MapRazorComponents<App>()
.AddServerRenderMode();
.AddInteractiveServerRenderMode();

app.Run();

0 comments on commit 5207579

Please sign in to comment.