I have an issue with the Forms. At first it was without a problem but after that I got an error.
This is the fist component:
@page "/recipe/create"
@using Model
@using DataAccess.Data
@using Models;
@using Microsoft.AspNetCore.Components.Forms
@Title Recipe
@{
var ingredientsString = RecipeModel.Ingredients != null ? string.Join(',', RecipeModel.Ingredients) : string.Empty;
}
@code {
private RecipeDto RecipeModel { get; set; } = new RecipeDto();
private string Title { get; set; } = "Create";
private DataAccess.Data.Recipe Recipe { get; set; } = new DataAccess.Data.Recipe();
private void CreateRecipe()
{
// Save the recipe to a database or other storage mechanism
}
}
And I get this error:
Error (active) RZ9985 Multiple components use the tag 'EditForm'. Components: BakingBeyondRecipesServer.Pages.EditForm, Microsoft.AspNetCore.Components.Forms.EditForm
And I have an warning and when I try to open this page there is a message displayed that there is nothing to show.
@page "/category/create"
@using DataAccess.Data
@using Models;
@using Microsoft.AspNetCore.Components.Forms
Create New Category
@code {
private DataAccess.Data.Recipe Recipe { get; set; } = new DataAccess.Data.Recipe();
private DataAccess.Data.Category Category {get;set;} = new DataAccess.Data.Category();
private CategoryDto CategoryModel = new CategoryDto();
private void HandleValidSubmit()
{
// Perform actions on form submission
}
}
I get those warnings:
Warning (active) RZ10012 Found markup element with unexpected name 'EditForm'. If this is intended to be a component, add a @using directive for its namespace.
Warning (active) RZ10012 Found markup element with unexpected name 'InputText'. If this is intended to be a component, add a @using directive for its namespace.
Tuhin PaulPosted Mar 26, 2023, 4:54 PM
Add a namespace directive for the Microsoft.AspNetCore.Components.Forms namespace to avoid conflicts with other components that might have a similar name.Add the following line at the top of your Razor page.
For the warnings regarding unexpected markup elements, you may need to add using directives for the namespaces of the corresponding components.
Rositsa RusevaPosted Mar 15, 2023, 9:32 AM
I found that in the Pages I have left an empty component named EditForm and I deleted it. But I still get the warning for the category create. And again when I start the program there is nothing displayed on this component
Amit MohantyPosted Mar 15, 2023, 6:04 AM
It appears that you have two components in your project that use the same tag name "EditForm". One is located in the namespace "BakingBeyondRecipesServer.Pages.EditForm" and the other is located in the namespace "Microsoft.AspNetCore.Components.Forms.EditForm". To avoid conflicts, you should give each component a unique tag name