I am a little confused about 3 last code box title's, actually about last one 'HTML' file type is correct because it contains some script's, but about two others before last one why their code box title's are not 'razor' and they are 'CSHTML' file.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hello @NaserParhizkar ... Those are Razor Pages that use the Component Tag Helper, so they're correct showing CSHTML.
_BUT_ ... I'm glad that you opened this issue to ask about those two sections. We created a topic a little while ago to cover integrating components into Razor pages and MVC views. I failed to move the content from this topic into the new topic. The new topic is at ...
https://docs.microsoft.com/aspnet/core/blazor/integrate-components
I'll use this issue to track moving those two sections. Leave this issue open. It will close automatically when the PR merges.
Thanks for commenting!
How to add '@code { // }' in a 'CSHTML' file?
Use @functions in Razor Pages ...
https://docs.microsoft.com/aspnet/core/mvc/views/razor#functions
@code is only for Razor components.
OK, based on your previous comment's '@code { }' should have been '@function { }' in those sections.
Is it correct?
Yes ... and I highly suspect _find and replace_ is what happened there. There was a time early on in the development of Blazor that Razor components also used @functions. Then, they created the @code directive as an alias of @functions (AFAIK, they'll both work there). I think I probably did a find-and-replace to "fix them" everywhere in Blazor topics ... well ... "fix" 🙈 ... you see how well that worked. :smile:
I'll go ahead and move those sections and patch the examples right now.
yes you right, I had forgotten about '@function{}' in 'Blazor file' previous releases.
Anyway ,Thank you very much, don't worry bro. it's great and I appropriate for your time and response's. Bless you.