Can't use a partial class NavMenu

Frank Mehlhop 66 Reputation points
2022-07-26T12:22:17.003+00:00

I'm using Shared/NavMenu.razor with html and C#.
Now I try the extract the C# to a newly created NavMenu.razor.cs.
But the cs class is not recognised from the system.
Also Visual Studio does not makes any highlighting at this class.

How can I extract the C# code from NavMenu into a own class?

224892-image.png

Note the lack of highlighting:

224867-image.png

Developer technologies | .NET | Blazor
{count} votes

Accepted answer
  1. Anonymous
    2022-07-27T03:36:01.657+00:00

    Hi @Frank Mehlhop ,

    Now I try the extract the C# to a newly created NavMenu.razor.cs.
    But the cs class is not recognised from the system.
    Also Visual Studio does not makes any highlighting at this class.

    After extracting the C# code to the NavMenu.razor.cs file, try to run the application, whether the application running success or is there any error? Try to create a new project to test it whether it works well in the new project?

    Based on your description, I create a Asp.net 6 Blazor Server application using VS 2022, everything works well. check this screenshot:

    225075-image.png

    and

    225102-1.gif

    How can I extract the C# code from NavMenu into a own class?

    You can refer the above screenshot to create the class by yourself, or you can also use the VS Quick Actions Extract block to code behind option to extract the C# code to a back-end class file. Refer to this screenshot:

    225085-2.gif


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.