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 ?
Thanks,
In Search.razor :
@page "/search"
@using Models
<RadzenTemplateForm TItem="SearchRequestModel" Data=@model Submit=@OnSubmit>
<div >
<div >
<RadzenCard>
<div >
<div >
<RadzenLabel Text="Cardholder" />
</div>
<div >
<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)
{
}
}
}
CodePudding user response:
The name of your partial class is supposed to match the name of the file of your razor page:
public partial class Search
It's a partial class for a razor page so you should name it Search.razor.cs
.
Here is the Doc.
CodePudding user response:
The razor file is named like this : That's work for me
Search.razor
// The file name can be Search.cs or Search.razor.cs both work
public partial class SearchBase : ComponentBase
{
}
In the razor page add this :
@inherits SearchBase