SlideShare a Scribd company logo
Writing
JavaScript
for C#'s
Blazor
#CODEPALOUSA
Ed Charbeneau
Author:
Sr. Developer Advocate
Progress Software,
Telerik UI for Blazor
“Blazor: A Beginner's Guide” (free)
Тwitter: @EdCharbeneau
Тwitch: Twitch.tv/EdCharbeneau
Blazor Component Architecture
Parameters
A PUBLIC PROPERTY
THAT CAN AFFECT
COMPONENT
RENDERING OR
HANDLE EVENT
DELEGATION.
[Parameter]
COMPONENT
<span>@Title<span>
[Parameter]
public string Title { get; set; }
USAGE
<Component Title=“value”/>
RenderFragment
& ChildContent
A
RENDERFRAGMENT
PARAMETER, BY
CONVENTION
DEFINES A
TEMPLATE REGION
RenderFragment & ChildContent
COMPONENT
<div>
@ChildContent
</div>
[Parameter]
public RenderFragment ChildContent {
get; set; }
USAGE
<Component>
<p>Some Child HTML, Razor,
or Component</p>
</Component>
Attribute
Splatting
ACCEPTS LOOSE
HTML ATTRIBUTES
WHICH CAN BE
APPLIED TO YOUR
COMPONENTS
RENDERED MARKUP
@attributes
COMPONENT
<div @attributes="AdditionalAttributes“>
[Parameter(CaptureUnmatchedValues = true)]
public IReadOnlyDictionary<string, object> AdditionalAttributes { get; set; }
USAGE
<Component class=“my-class” id=“my-id”>
Generic
Templates
A COMPONENT THAT
TAKES A GENERIC ITEM
<T> AND APPLIES IT TO
A TEMPLATE,
RENDERFRAGMENT<T>
RenderFragment<T> & TItem
COMPONENT
@typeparam Titem
@foreach (var item in Items)
{
@ItemTemplate(item)
}
[Parameter]
public RenderFragment<TItem> ItemTemplate { get; set; }
[Parameter]
public IReadOnlyList<TItem> Items { get; set; }
USAGE
<FooList Items=“item[]">
<ItemTemplate>
<div>
<h2>Id: @context.Id</h2>
<p>@context.Message</p>
</div>
</ItemTemplate>
</FooList>
EventCallback<T
>
AN EVENT DELEGATE
FOR BLAZOR THAT
TRIGGERS A
COMPONENT RE-
RENDER
EventCallback<T>
COMPONENT
[Parameter]
public EventCallback<object> OnDelete
{ get; set; }
void HandleDelete(TItem item) =>
OnDelete.InvokeAsync(item);
USAGE
<Component OnDelete=“MyDelete”>
Expensive - Only use EventCallback at the consumer API level of your component
EventCallback<TItem>: Scope
COMPONENT
[Parameter]
public EventCallback<TItem> OnDelete { get; set; }
USAGE
<Component OnDelete="@((LogItem e) => DeleteItem(e))" >
void DeleteItem(LogItem item) // TItem????
{
logs.LogItems.Remove(item);
}
EventCallback<T> Error cannot convert from 'method group' to 'EventCallback'
Code Behind
THE TECHNIQUE OF
USING A SEPARATE FILE
FOR MARKUP AND
LOGIC
Code Behind
MARKUP
<span>@Title<span>
CODE
public partial class Foo
{
[Parameter]
public string Title { get; set; }
}
Foo.razor Foo.razor.cs
Questions
#CodePalousa
Resources
1. EdCharbeneau.com
• Free Ebook & examples
• GitHub
• Twitter
• Twitch
2. Blogs.Telerik.com

More Related Content

What's hot (15)

PDF
Email authentication using firebase auth + flutter
Katy Slemon
 
PDF
iOSDevCamp Firebase Overview
James Daniels
 
PPTX
Ember components
Sarath Chandra
 
PPTX
Introduction to google endpoints
Shinto Anto
 
PDF
Beginning AngularJS
Troy Miles
 
PDF
A Practical Approach to React Native at All Things Open Conference
Tracy Lee
 
PDF
Building Faster With Your Team's UI Kit
Atlassian
 
PPTX
Building The SpringGraph Flex Component
Guo Albert
 
PDF
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
Tim Pettersen
 
PDF
Techical Workflow for a Startup
Sébastien Saunier
 
PDF
React native app with type script tutorial
Katy Slemon
 
PPTX
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
PDF
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
PPT
Rails Plugins 1 Plugin
oscon2007
 
PDF
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Codemotion
 
Email authentication using firebase auth + flutter
Katy Slemon
 
iOSDevCamp Firebase Overview
James Daniels
 
Ember components
Sarath Chandra
 
Introduction to google endpoints
Shinto Anto
 
Beginning AngularJS
Troy Miles
 
A Practical Approach to React Native at All Things Open Conference
Tracy Lee
 
Building Faster With Your Team's UI Kit
Atlassian
 
Building The SpringGraph Flex Component
Guo Albert
 
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
Tim Pettersen
 
Techical Workflow for a Startup
Sébastien Saunier
 
React native app with type script tutorial
Katy Slemon
 
Why I am hooked on the future of React
Maurice De Beijer [MVP]
 
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 
Rails Plugins 1 Plugin
oscon2007
 
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Codemotion
 

Similar to Secrets of a Blazor Component Artisan (v2) (20)

PPTX
Blazor - the successor of angular/react/vue?
Robert Szachnowski
 
PDF
Blazor web apps
Rajesh Kolla
 
PPTX
Blazor - An Introduction
JamieTaylor112
 
PPTX
Blazor Components
Jose Javier Columbie
 
PPTX
What Is Blazor? A Complete Guide to Getting Started
simonedaniels3
 
PPTX
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Fwdays
 
PPTX
Goodbye JavaScript Hello Blazor
Ed Charbeneau
 
PDF
Blazor in Action 1st Edition Chris Sainty
khakontovo
 
PDF
Blazor in Action 1st Edition Chris Sainty
idelmomunure
 
PPTX
Blazor
Sandun Perera
 
PPTX
Full stack web development with c# and web assembly - Blazor.Net
Ruwantha Ratnayake
 
PPTX
Blazor
Ed Charbeneau
 
PPTX
Oleksandr Skachkov "Running С# in your Web Browser with WebAssembly"
Fwdays
 
PPTX
Blazor.pptx
ssuserb1d1a2
 
PDF
Blazor - The New Silverlight?
Christian Nagel
 
PDF
Blazor certification training - Dot Net Tricks
Gaurav Singh
 
PDF
#6 | Component Lifecycles | Microsoft Blazor | Sameer Siddiqui
SameerAhmedSiddiqui1
 
PDF
Blazor, lo sapevi che...
Andrea Dottor
 
PDF
Pre-render Blazor WebAssembly on static web hosting at publishing time
Jun-ichi Sakamoto
 
PPTX
A Gentle Introduction to Blazor
Jose Javier Columbie
 
Blazor - the successor of angular/react/vue?
Robert Szachnowski
 
Blazor web apps
Rajesh Kolla
 
Blazor - An Introduction
JamieTaylor112
 
Blazor Components
Jose Javier Columbie
 
What Is Blazor? A Complete Guide to Getting Started
simonedaniels3
 
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Fwdays
 
Goodbye JavaScript Hello Blazor
Ed Charbeneau
 
Blazor in Action 1st Edition Chris Sainty
khakontovo
 
Blazor in Action 1st Edition Chris Sainty
idelmomunure
 
Full stack web development with c# and web assembly - Blazor.Net
Ruwantha Ratnayake
 
Oleksandr Skachkov "Running С# in your Web Browser with WebAssembly"
Fwdays
 
Blazor.pptx
ssuserb1d1a2
 
Blazor - The New Silverlight?
Christian Nagel
 
Blazor certification training - Dot Net Tricks
Gaurav Singh
 
#6 | Component Lifecycles | Microsoft Blazor | Sameer Siddiqui
SameerAhmedSiddiqui1
 
Blazor, lo sapevi che...
Andrea Dottor
 
Pre-render Blazor WebAssembly on static web hosting at publishing time
Jun-ichi Sakamoto
 
A Gentle Introduction to Blazor
Jose Javier Columbie
 
Ad

More from Ed Charbeneau (18)

PPTX
Writing JavaScript for C# Blazor.pptx
Ed Charbeneau
 
PPTX
Blazor Stability Testing Tools for Bullet Proof Applications
Ed Charbeneau
 
PPTX
Modernizing Web Apps with .NET 6.pptx
Ed Charbeneau
 
PPTX
Modernizing Web Apps with .NET 6.pptx
Ed Charbeneau
 
PPTX
Blazor Full-Stack
Ed Charbeneau
 
PPTX
Secrets of a Blazor Component Artisan
Ed Charbeneau
 
PPTX
Writing java script for Csharp's Blazor
Ed Charbeneau
 
PPTX
Razor into the Razor'verse
Ed Charbeneau
 
PPTX
Giving Clarity to LINQ Queries by Extending Expressions R2
Ed Charbeneau
 
PPTX
The future of .NET lightning talk
Ed Charbeneau
 
PPTX
Into the next dimension
Ed Charbeneau
 
PPTX
Giving Clarity to LINQ Queries by Extending Expressions
Ed Charbeneau
 
PPTX
What is new in Q2 2015
Ed Charbeneau
 
PPTX
TelerikNEXT What's new in UI for ASP.NET AJAX
Ed Charbeneau
 
PPTX
Journey to JavaScript (from C#)
Ed Charbeneau
 
PPTX
Refactoring css
Ed Charbeneau
 
PPTX
Don't be a stereotype: Rapid Prototype
Ed Charbeneau
 
PPTX
A crash course in responsive design
Ed Charbeneau
 
Writing JavaScript for C# Blazor.pptx
Ed Charbeneau
 
Blazor Stability Testing Tools for Bullet Proof Applications
Ed Charbeneau
 
Modernizing Web Apps with .NET 6.pptx
Ed Charbeneau
 
Modernizing Web Apps with .NET 6.pptx
Ed Charbeneau
 
Blazor Full-Stack
Ed Charbeneau
 
Secrets of a Blazor Component Artisan
Ed Charbeneau
 
Writing java script for Csharp's Blazor
Ed Charbeneau
 
Razor into the Razor'verse
Ed Charbeneau
 
Giving Clarity to LINQ Queries by Extending Expressions R2
Ed Charbeneau
 
The future of .NET lightning talk
Ed Charbeneau
 
Into the next dimension
Ed Charbeneau
 
Giving Clarity to LINQ Queries by Extending Expressions
Ed Charbeneau
 
What is new in Q2 2015
Ed Charbeneau
 
TelerikNEXT What's new in UI for ASP.NET AJAX
Ed Charbeneau
 
Journey to JavaScript (from C#)
Ed Charbeneau
 
Refactoring css
Ed Charbeneau
 
Don't be a stereotype: Rapid Prototype
Ed Charbeneau
 
A crash course in responsive design
Ed Charbeneau
 
Ad

Recently uploaded (20)

PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
PPTX
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
PDF
Best Web development company in india 2025
Greenusys
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
PDF
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PDF
Windows 10 Professional Preactivated.pdf
asghxhsagxjah
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
Function & Procedure: Function Vs Procedure in PL/SQL
Shani Tiwari
 
Best Web development company in india 2025
Greenusys
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
Meet in the Middle: Solving the Low-Latency Challenge for Agentic AI
Alluxio, Inc.
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
Windows 10 Professional Preactivated.pdf
asghxhsagxjah
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 

Secrets of a Blazor Component Artisan (v2)