Skip to content

Commit 12b72dd

Browse files
committed
Added missing files and updated the sample
1 parent 5234369 commit 12b72dd

34 files changed

+1239
-188
lines changed

App.razor

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Router AppAssembly="@typeof(App).Assembly">
22
<Found Context="routeData">
3-
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4-
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1"/>
55
</Found>
66
<NotFound>
77
<PageTitle>Not found</PageTitle>
88
<LayoutView Layout="@typeof(MainLayout)">
99
<p role="alert">Sorry, there's nothing at this address.</p>
1010
</LayoutView>
1111
</NotFound>
12-
</Router>
12+
</Router>

Blazor_EditForm.csproj

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net7.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.Blazor" Version="25.2.7" />
11+
<PackageReference Include="Syncfusion.Blazor.Themes" Version="25.2.7" />
12+
</ItemGroup>
13+
14+
</Project>

Blazor_EditForm.sln

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Blazor_EditForm", "Blazor_EditForm.csproj", "{DC1EFAC9-1F6C-46C4-9B25-F3C80A03CD1B}"
4+
EndProject
5+
Global
6+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7+
Debug|Any CPU = Debug|Any CPU
8+
Release|Any CPU = Release|Any CPU
9+
EndGlobalSection
10+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
11+
{DC1EFAC9-1F6C-46C4-9B25-F3C80A03CD1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
12+
{DC1EFAC9-1F6C-46C4-9B25-F3C80A03CD1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
13+
{DC1EFAC9-1F6C-46C4-9B25-F3C80A03CD1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
14+
{DC1EFAC9-1F6C-46C4-9B25-F3C80A03CD1B}.Release|Any CPU.Build.0 = Release|Any CPU
15+
EndGlobalSection
16+
EndGlobal

Data/EmployeeDetails.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.ComponentModel.DataAnnotations;
55
using System.Runtime.CompilerServices;
66

7-
namespace EditFormValidation.Data
7+
namespace Blazor_EditForm.Data
88
{
99
/// <summary>
1010
/// Get the employee details

Data/WeatherForecast.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
namespace EditFormValidation.Data
1+
namespace Blazor_EditForm.Data;
2+
3+
public class WeatherForecast
24
{
3-
public class WeatherForecast
4-
{
5-
public DateOnly Date { get; set; }
5+
public DateOnly Date { get; set; }
66

7-
public int TemperatureC { get; set; }
7+
public int TemperatureC { get; set; }
88

9-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1010

11-
public string? Summary { get; set; }
12-
}
11+
public string? Summary { get; set; }
1312
}

Data/WeatherForecastService.cs

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
namespace EditFormValidation.Data
1+
namespace Blazor_EditForm.Data;
2+
3+
public class WeatherForecastService
24
{
3-
public class WeatherForecastService
5+
private static readonly string[] Summaries = new[]
46
{
5-
private static readonly string[] Summaries = new[]
6-
{
77
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
88
};
99

10-
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
10+
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
11+
{
12+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
1113
{
12-
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
13-
{
14-
Date = startDate.AddDays(index),
15-
TemperatureC = Random.Shared.Next(-20, 55),
16-
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
17-
}).ToArray());
18-
}
14+
Date = startDate.AddDays(index),
15+
TemperatureC = Random.Shared.Next(-20, 55),
16+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
17+
}).ToArray());
1918
}
2019
}

EditFormValidation.csproj

-17
This file was deleted.

EditFormValidation.sln

-25
This file was deleted.

Pages/Counter.razor

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
19+
}

Pages/Error.cshtml

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
@page
2-
@model EditFormValidation.Pages.ErrorModel
2+
@model Blazor_EditForm.Pages.ErrorModel
33

44
<!DOCTYPE html>
55
<html lang="en">
66

77
<head>
8-
<meta charset="utf-8" />
9-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
8+
<meta charset="utf-8"/>
9+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
1010
<title>Error</title>
11-
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
12-
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
11+
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet"/>
12+
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true"/>
1313
</head>
1414

1515
<body>
16-
<div class="main">
17-
<div class="content px-4">
18-
<h1 class="text-danger">Error.</h1>
19-
<h2 class="text-danger">An error occurred while processing your request.</h2>
16+
<div class="main">
17+
<div class="content px-4">
18+
<h1 class="text-danger">Error.</h1>
19+
<h2 class="text-danger">An error occurred while processing your request.</h2>
2020

21-
@if (Model.ShowRequestId)
22-
{
23-
<p>
24-
<strong>Request ID:</strong> <code>@Model.RequestId</code>
25-
</p>
26-
}
27-
28-
<h3>Development Mode</h3>
29-
<p>
30-
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
31-
</p>
21+
@if (Model.ShowRequestId)
22+
{
3223
<p>
33-
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
34-
It can result in displaying sensitive information from exceptions to end users.
35-
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
36-
and restarting the app.
24+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
3725
</p>
38-
</div>
26+
}
27+
28+
<h3>Development Mode</h3>
29+
<p>
30+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
31+
</p>
32+
<p>
33+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
34+
It can result in displaying sensitive information from exceptions to end users.
35+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
36+
and restarting the app.
37+
</p>
3938
</div>
39+
</div>
4040
</body>
4141

42-
</html>
42+
</html>

Pages/Error.cshtml.cs

+17-18
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using System.Diagnostics;
2+
using Microsoft.AspNetCore.Mvc;
23
using Microsoft.AspNetCore.Mvc.RazorPages;
3-
using System.Diagnostics;
44

5-
namespace EditFormValidation.Pages
5+
namespace Blazor_EditForm.Pages;
6+
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
610
{
7-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8-
[IgnoreAntiforgeryToken]
9-
public class ErrorModel : PageModel
10-
{
11-
public string? RequestId { get; set; }
11+
public string? RequestId { get; set; }
1212

13-
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1414

15-
private readonly ILogger<ErrorModel> _logger;
15+
private readonly ILogger<ErrorModel> _logger;
1616

17-
public ErrorModel(ILogger<ErrorModel> logger)
18-
{
19-
_logger = logger;
20-
}
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
2121

22-
public void OnGet()
23-
{
24-
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25-
}
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
2625
}
2726
}

Pages/FetchData.razor

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
@page "/fetchdata"
2+
@using Blazor_EditForm.Data
3+
@inject WeatherForecastService ForecastService
4+
5+
<PageTitle>Weather forecast</PageTitle>
6+
7+
<h1>Weather forecast</h1>
8+
9+
<p>This component demonstrates fetching data from a service.</p>
10+
11+
@if (forecasts == null)
12+
{
13+
<p>
14+
<em>Loading...</em>
15+
</p>
16+
}
17+
else
18+
{
19+
<table class="table">
20+
<thead>
21+
<tr>
22+
<th>Date</th>
23+
<th>Temp. (C)</th>
24+
<th>Temp. (F)</th>
25+
<th>Summary</th>
26+
</tr>
27+
</thead>
28+
<tbody>
29+
@foreach (var forecast in forecasts)
30+
{
31+
<tr>
32+
<td>@forecast.Date.ToShortDateString()</td>
33+
<td>@forecast.TemperatureC</td>
34+
<td>@forecast.TemperatureF</td>
35+
<td>@forecast.Summary</td>
36+
</tr>
37+
}
38+
</tbody>
39+
</table>
40+
}
41+
42+
@code {
43+
private WeatherForecast[]? forecasts;
44+
45+
protected override async Task OnInitializedAsync()
46+
{
47+
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
48+
}
49+
50+
}

0 commit comments

Comments
 (0)