SlideShare ist ein Scribd-Unternehmen logo
1 von 17
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

Weitere ähnliche Inhalte

Was ist angesagt?

Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
Troy Miles
 
Building The SpringGraph Flex Component
Building The SpringGraph Flex ComponentBuilding The SpringGraph Flex Component
Building The SpringGraph Flex Component
Guo Albert
 
Rails Plugins 1 Plugin
Rails Plugins 1 PluginRails Plugins 1 Plugin
Rails Plugins 1 Plugin
oscon2007
 

Was ist angesagt? (15)

Email authentication using firebase auth + flutter
Email authentication using firebase auth + flutterEmail authentication using firebase auth + flutter
Email authentication using firebase auth + flutter
 
iOSDevCamp Firebase Overview
iOSDevCamp Firebase OverviewiOSDevCamp Firebase Overview
iOSDevCamp Firebase Overview
 
Ember components
Ember componentsEmber components
Ember components
 
Introduction to google endpoints
Introduction to google endpointsIntroduction to google endpoints
Introduction to google endpoints
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
A Practical Approach to React Native at All Things Open Conference
A Practical Approach to React Native at All Things Open ConferenceA Practical Approach to React Native at All Things Open Conference
A Practical Approach to React Native at All Things Open Conference
 
Building Faster With Your Team's UI Kit
Building Faster With Your Team's UI KitBuilding Faster With Your Team's UI Kit
Building Faster With Your Team's UI Kit
 
Building The SpringGraph Flex Component
Building The SpringGraph Flex ComponentBuilding The SpringGraph Flex Component
Building The SpringGraph Flex Component
 
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API EconomyRewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
 
Techical Workflow for a Startup
Techical Workflow for a StartupTechical Workflow for a Startup
Techical Workflow for a Startup
 
React native app with type script tutorial
React native app with type script tutorialReact native app with type script tutorial
React native app with type script tutorial
 
Why I am hooked on the future of React
Why I am hooked on the future of ReactWhy I am hooked on the future of React
Why I am hooked on the future of React
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Rails Plugins 1 Plugin
Rails Plugins 1 PluginRails Plugins 1 Plugin
Rails Plugins 1 Plugin
 
Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017Make your animations perform well - Anna Migas - Codemotion Rome 2017
Make your animations perform well - Anna Migas - Codemotion Rome 2017
 

Ähnlich wie Secrets of a Blazor Component Artisan (v2)

CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
Ciklum Ukraine
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 
Parkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_badaParkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_bada
웹데브모바일
 

Ähnlich wie Secrets of a Blazor Component Artisan (v2) (20)

Salesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web ComponentSalesforce meetup | Lightning Web Component
Salesforce meetup | Lightning Web Component
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
09 Asp.Net MVC Data Validation.pptx
09 Asp.Net MVC Data Validation.pptx09 Asp.Net MVC Data Validation.pptx
09 Asp.Net MVC Data Validation.pptx
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoas
 
Spring and DWR
Spring and DWRSpring and DWR
Spring and DWR
 
Getting Started with React v16
Getting Started with React v16Getting Started with React v16
Getting Started with React v16
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
AngularDart - Meetup 15/03/2017
AngularDart - Meetup 15/03/2017AngularDart - Meetup 15/03/2017
AngularDart - Meetup 15/03/2017
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Plugins
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
Os Johnson
Os JohnsonOs Johnson
Os Johnson
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Developing Web Services from Scratch - For DBAs and Database Developers
Developing Web Services from Scratch - For DBAs and Database DevelopersDeveloping Web Services from Scratch - For DBAs and Database Developers
Developing Web Services from Scratch - For DBAs and Database Developers
 
Parkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_badaParkjihoon phonegap research_for_bada
Parkjihoon phonegap research_for_bada
 
Introduction to react
Introduction to reactIntroduction to react
Introduction to react
 
Google Wave API: Now and Beyond
Google Wave API: Now and BeyondGoogle Wave API: Now and Beyond
Google Wave API: Now and Beyond
 

Mehr von Ed Charbeneau

Mehr von Ed Charbeneau (20)

Writing JavaScript for C# Blazor.pptx
Writing JavaScript for C# Blazor.pptxWriting JavaScript for C# Blazor.pptx
Writing JavaScript for C# Blazor.pptx
 
Blazor Stability Testing Tools for Bullet Proof Applications
Blazor Stability Testing Tools for Bullet Proof ApplicationsBlazor Stability Testing Tools for Bullet Proof Applications
Blazor Stability Testing Tools for Bullet Proof Applications
 
Modernizing Web Apps with .NET 6.pptx
Modernizing Web Apps with .NET 6.pptxModernizing Web Apps with .NET 6.pptx
Modernizing Web Apps with .NET 6.pptx
 
Modernizing Web Apps with .NET 6.pptx
Modernizing Web Apps with .NET 6.pptxModernizing Web Apps with .NET 6.pptx
Modernizing Web Apps with .NET 6.pptx
 
Blazor Full-Stack
Blazor Full-StackBlazor Full-Stack
Blazor Full-Stack
 
Secrets of a Blazor Component Artisan
Secrets of a Blazor Component ArtisanSecrets of a Blazor Component Artisan
Secrets of a Blazor Component Artisan
 
Writing java script for Csharp's Blazor
Writing java script for Csharp's BlazorWriting java script for Csharp's Blazor
Writing java script for Csharp's Blazor
 
Goodbye JavaScript Hello Blazor
Goodbye JavaScript Hello BlazorGoodbye JavaScript Hello Blazor
Goodbye JavaScript Hello Blazor
 
Razor into the Razor'verse
Razor into the Razor'verseRazor into the Razor'verse
Razor into the Razor'verse
 
Blazor
BlazorBlazor
Blazor
 
Giving Clarity to LINQ Queries by Extending Expressions R2
Giving Clarity to LINQ Queries by Extending Expressions R2Giving Clarity to LINQ Queries by Extending Expressions R2
Giving Clarity to LINQ Queries by Extending Expressions R2
 
The future of .NET lightning talk
The future of .NET lightning talkThe future of .NET lightning talk
The future of .NET lightning talk
 
Into the next dimension
Into the next dimensionInto the next dimension
Into the next dimension
 
Giving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending ExpressionsGiving Clarity to LINQ Queries by Extending Expressions
Giving Clarity to LINQ Queries by Extending Expressions
 
What is new in Q2 2015
What is new in Q2 2015What is new in Q2 2015
What is new in Q2 2015
 
TelerikNEXT What's new in UI for ASP.NET AJAX
TelerikNEXT What's new in UI for ASP.NET AJAXTelerikNEXT What's new in UI for ASP.NET AJAX
TelerikNEXT What's new in UI for ASP.NET AJAX
 
Journey to JavaScript (from C#)
Journey to JavaScript (from C#)Journey to JavaScript (from C#)
Journey to JavaScript (from C#)
 
Refactoring css
Refactoring cssRefactoring css
Refactoring css
 
Don't be a stereotype: Rapid Prototype
Don't be a stereotype: Rapid PrototypeDon't be a stereotype: Rapid Prototype
Don't be a stereotype: Rapid Prototype
 
A crash course in responsive design
A crash course in responsive designA crash course in responsive design
A crash course in responsive design
 

Kürzlich hochgeladen

Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
drm1699
 

Kürzlich hochgeladen (20)

OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Abortion Pill Prices Polokwane ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Polokwane ](+27832195400*)[ 🏥 Women's Abortion Clinic in...Abortion Pill Prices Polokwane ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
Abortion Pill Prices Polokwane ](+27832195400*)[ 🏥 Women's Abortion Clinic in...
 
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
 
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
Abortion Pill Prices Jane Furse ](+27832195400*)[ 🏥 Women's Abortion Clinic i...
 
Your Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | EvmuxYour Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | Evmux
 
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
Abortion Clinic In Pretoria ](+27832195400*)[ 🏥 Safe Abortion Pills in Pretor...
 
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
CERVED e Neo4j su una nuvola, migrazione ed evoluzione di un grafo mission cr...
 
微信号购买
微信号购买微信号购买
微信号购买
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
A Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdfA Deep Dive into Secure Product Development Frameworks.pdf
A Deep Dive into Secure Product Development Frameworks.pdf
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
Abortion Clinic in Bloemfontein [(+27832195400*)]🏥Safe Abortion Pills In Bloe...
Abortion Clinic in Bloemfontein [(+27832195400*)]🏥Safe Abortion Pills In Bloe...Abortion Clinic in Bloemfontein [(+27832195400*)]🏥Safe Abortion Pills In Bloe...
Abortion Clinic in Bloemfontein [(+27832195400*)]🏥Safe Abortion Pills In Bloe...
 
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
Abortion Pills For Sale WhatsApp[[+27737758557]] In Birch Acres, Abortion Pil...
 
Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?Prompt Engineering - an Art, a Science, or your next Job Title?
Prompt Engineering - an Art, a Science, or your next Job Title?
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMs
 
Abortion Pill Prices Aliwal North ](+27832195400*)[ 🏥 Women's Abortion Clinic...
Abortion Pill Prices Aliwal North ](+27832195400*)[ 🏥 Women's Abortion Clinic...Abortion Pill Prices Aliwal North ](+27832195400*)[ 🏥 Women's Abortion Clinic...
Abortion Pill Prices Aliwal North ](+27832195400*)[ 🏥 Women's Abortion Clinic...
 
[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)
 

Secrets of a Blazor Component Artisan (v2)