Skip to content

Instantly share code, notes, and snippets.

View EdCharbeneau's full-sized avatar
🏠
Working from home

Ed Charbeneau EdCharbeneau

🏠
Working from home
View GitHub Profile
@EdCharbeneau
EdCharbeneau / RemoteAuthenticatorView.razor
Created June 4, 2020 15:41
All the RemoteAuthenticatorView templates
<RemoteAuthenticatorView Action="@Action">
<LoggingIn>
<span>Logging you in...</span>
</LoggingIn>
<CompletingLoggingIn>
<span>Checking permissions...</span>
</CompletingLoggingIn>
<LogInFailed>
<span>Sorry, your login failed. Please try again or contact support.</span>
</LogInFailed>
@EdCharbeneau
EdCharbeneau / How to use Razor Components with Auth.md
Last active August 13, 2021 14:05
Blazor powered auth pages

A tip sent to me by Brian Douglass...

The way it works is:

  • Create a new Server project with Identity activated, but no scaffolding
  • Modify Startup.cs to add the AF token as a header
  • Create a custom SignIn.razor
    • Collects credentials in a form
    • OnValidSubmit() after checking validity of credentials
      • Make Http call to Login.OnGet() and get the form, with the AF token attached
  • Build new request with Credentials + AF token in the Form data + AF token in the header.
@EdCharbeneau
EdCharbeneau / ExampleMetadata.cs
Last active May 3, 2020 14:28
Create a menu from Application components.
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
public static class ExampleMetadata
{
public static IEnumerable<MenuItem> GetItems()
@EdCharbeneau
EdCharbeneau / foo.ts
Last active April 17, 2020 22:04
TypeWtf
export MyClass {
private foo: string = "hello";
public addHandler() {
window.addEventListener("resize", this.logResize);
}
public logResize() {
console.log(this); // Expected: MyClass | Actual: Window
ABOUT ED:
Ed is a Microsoft MVP and an international speaker, writer, online influencer, a Developer Advocate for Progress - [Telerik UI for Blazor](https://www.telerik.com/blazor-ui), and expert on all things web development. Ed enjoys geeking out to cool new tech, brainstorming about future technology, and admiring great design.
@EdCharbeneau
EdCharbeneau / Index.razor.cs
Last active January 27, 2020 22:58
Cancelable Event
void HandleTabChange(TabEventArgs args)
{
var value = (Foo)args.Value;
if (value.Id == 1)
{
args.Cancel = true;
}
else
{
SelectedItem = value;
@EdCharbeneau
EdCharbeneau / AlertBox.razor
Last active August 17, 2020 17:26
EventCallbacks
<div class="alert alert-danger">
@ChildContent
</div>
@code {
[Parameter] public RenderFragment ChildContent { get; set; }
}
@EdCharbeneau
EdCharbeneau / little-guy.md
Created November 20, 2019 21:37
But I'm an independent contractor.

Today I went to the lumber yard to get some tools and materials. I explained to the manager that I was building a deck for a neighbor and I needed supplies. I explained that I'm an independent contractor and I would like all of the tools and materials for free since I'm really not making a huge profit yet, and I'm only a small one person business. The manager said I could borrow some tools for 30 days, but had to buy them at the end of the trial period. He wasn't flexible on pricing for lumber either, I guess he just doesn't care about the small contractor AT ALL! I think I can get some pallets from the recycling center, enough to get started and move on to the next project. Maybe when I get ready for my next job these big companies will finally care about the little guy. Running a small independent contracting business is so difficult these days because of this.

@if (IsLoading)
{
@LoadingTemplate
}
else
{
@ContentTemplate
}
@code {
@EdCharbeneau
EdCharbeneau / FetchData.razor
Created August 15, 2019 17:15
Working Grid with Template
@page "/fetchdata"
@inject HttpClient Http
@using Telerik.Blazor.Components.Grid
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from the server.</p>
<TelerikGrid Data="@forecasts" Pageable="true" Sortable="true" Filterable="true">
<TelerikGridColumns>