Skip to content

Instantly share code, notes, and snippets.

Talking Dotnet talkingdotnet

View GitHub Profile
View Blazor_Index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">
<base href="/" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
</head>
View fetchdata.component.dropdown.html
<div>
<label>Summary: </label>
<select (change)="filterForeCasts($event.target.value)">
<option value="0">--All--</option>
<option *ngFor="let summary of summaries" value={{summary}}>
{{summary}}
</option>
</select>
</div>
View fetchdata.component.dropdown.ts
import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'fetchdata',
templateUrl: './fetchdata.component.html'
})
export class FetchDataComponent {
public forecasts: WeatherForecast[];
public cacheForecasts: WeatherForecast[];
View FetchDataGetSummaries.cs
private static string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
[HttpGet("[action]")]
public string[] GetSummaries()
{
return Summaries;
}
View ToDoWithoutJS.cshtml
@page "/anothertodo"
@using ASPNETBlazorCRUDApp.Shared
@inject HttpClient Http
<h1>ToDo List</h1>
<div>
<div class="row">
<div class="col-sm-1">
<p>Item:</p>
View ToDoListController.cs
[Produces("application/json")]
[Route("api/ToDo")]
public class ToDoListController : Controller
{
private readonly ToDoListContext _context;
public ToDoListController(ToDoListContext context)
{
_context = context;
}
View ToDo.html
@page "/todo"
@using ASPNETBlazorCRUDApp.Shared
@using Microsoft.AspNetCore.Blazor.Browser.Interop
@inject HttpClient Http
<h1>ToDo List</h1>
<div>
<div class="row">
<div class="col-sm-1">
View NavMenu.html
<li>
<NavLink href="/todo">
<span class='glyphicon glyphicon-list-alt'></span> To Do
</NavLink>
</li>
View BlazorStartupConfigureMethod.cs
public void ConfigureServices(IServiceCollection services)
{
// Use Entity Framework in-memory provider for this sample
services.AddDbContext<ToDoListContext>(options => options.UseInMemoryDatabase("ToDoList"));
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
});
View ToDoListContext.cs
public class ToDoListContext : DbContext
{
public ToDoListContext(DbContextOptions<ToDoListContext> options) : base(options) { }
public DbSet<ToDoList> ToDoLists { get; set; }
}
You can’t perform that action at this time.