How split UI code from razor page to class with blazor

I get 2 errors with the code below

  • The name 'model' does not exist in the current context
  • The name 'OnSubmit' does not exist in the current context

The .cs code in the razor page in @code {} works

I tried with public partial class SearchRequest: ComponentBase but still the errors.

I use .NET 6

Do you have an idea ? Is it razden specific ?

Thanks,

In Search.razor :

@page "/search"
@using Models

<RadzenTemplateForm TItem="SearchRequestModel" Data=@model Submit=@OnSubmit>
    <div class="row px-3">
        <div class="col-12 col-lg-6 p-3">
            <RadzenCard>

                <div class="row">
                    <div class="col-md-4 align-items-center d-flex">
                        <RadzenLabel Text="Cardholder" />
                    </div>
                    <div class="col-md-8">
                        <RadzenTextBox style="width: 100%;" Name="CardHolder" />
                    </div>
                </div>

            </RadzenCard>
        </div>
    </div>
</RadzenTemplateForm>

In Search.cs :

namespace MyApp.Pages
{
    public partial class SearchRequest
    {
        public SearchModel model { get; set; } = new SearchModel();

        void OnSubmit(SearchModel searchModel)
        {
        }
    }
}

No.

Yes, you need @inherits in your razor: