blazor project for cs

This commit is contained in:
Norm Rasmussen
2022-06-09 22:22:29 -04:00
parent a12dc47d97
commit 6b46bc3f67
862 changed files with 26395 additions and 5 deletions

View File

@ -0,0 +1,18 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}

View File

@ -0,0 +1,57 @@
@page "/fetchdata"
@inject HttpClient Http
<PageTitle>Weather forecast</PageTitle>
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from the server.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}

View File

@ -0,0 +1,9 @@
@page "/"
<PageTitle>Index</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.
<SurveyPrompt Title="How is Blazor working for you?" />

View File

@ -0,0 +1,29 @@
@page "/todo"
<h3>Accounts</h3>
<input @bind="newTodoItem" type = "Enter Item">
<button @onclick="Save"> Save </button>
@if (todoList.Count > 0)
{
<ul style="list-style: none">
@foreach (TodoItem todo in todoList)
{
<li>
<input type="checkbox" @bind="todo.IsComplete" />
<span style = "@(todo.IsComplete ? "text-decoration: line-through" : "")">@todo.Title</span>
</li>
}
</ul>
}
@code {
private List<TodoItem> todoList = new List<TodoItem>();
private string newTodoItem { get; set; }
private void Save()
{
if (!string.IsNullOrWhiteSpace(newTodoItem))
{
todoList.Add(new TodoItem(newTodoItem));
newTodoItem = string.Empty;
}
}
}