Is anyone using the code from the free book and getting it to build/run?
I can't get past the event call back code on pages 46-47. I find the code references OnSelected="HandleItemSelected" delegate when no procedure/var exists with that name. I think I need to add a delegate to WeatherDay component.
Book:
<WeatherDay TemperatureC="forecast.TemperatureC"
Summary="@forecast.Summary"
DayOfWeek="forecast.Date.DayOfWeek"
OnSelected="HandleItemSelected"
Selected="forecast.Selected">
I tried:
<WeatherDay TemperatureC="forecast.TemperatureC"
Summary="@forecast.Summary"
DayOfWeek="forecast.Date.DayOfWeek"
OnSelected="HandleOnSelected"
Selected="forecast.Selected">
2 Answers, 1 is accepted
Hi Kenneth,
Thank you for reaching out. Indeed, it seems that a sample handler is missing from the book, and I will forward this issue to the people working on it.
Here's a sample handler that you can try in the WeeklyForecast.razor file (I am also attaching a runnable project that demonstrates it):
async Task HandleItemSelected(DayOfWeek day)
{
WeatherForecast selectedForecast = forecasts.Where(f => f.Date.DayOfWeek == day).First();
if(selectedForecast != null)
{
selectedForecast.Selected = !selectedForecast.Selected;
}
}
Regards,
Marin Bratanov
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Almost 2 years later, and the book has not yet been corrected?
Also other 'typos' like
above Summary="@forecast.Summary" where the leading @ is not needed
page 25 "API endpionts for data" (endpoints spelled wrong)
page 33 "where it should to be placed"
page 66 "diffing algorithm to to ensure"
Hi Dennis,
I've reached out to the author of the book. We are now waiting for a response. I will keep you updated.
Thank you for your patience while we investigate the matter here.
above Summary="@forecast.Summary" where the leading @ is not needed
Addressing the typos, however the statement above is correct.
Because the parameter Summary is a String, if the `@` is omitted then the value becomes the string literal "forecast.Summary" and not the value of the property `forecast.Summary`.
Thanks for making me aware of these issues. There are currently plans to replace the ebook with a much larger and complete ebook from O'Riley for free to our customers and community 🥳
In the mean time Ill see if theres a way to quicky address the typos described here.
Best regards,
Ed Charbeneau
Thanks Ed. Hopefully you will use Visual Studio 2022 / .NET 6, and address the warnings, etc. ;)
(Also, for Theme Chooser demo, it's not clear about where light.css and dark.css come from and where to reference them.)