Error when using components in if blazor server side
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
is if:
not if, work:
Code:
<Row>
<Col Class="basis-8/12">
<Card>
<Title>Test</Title>
<Content></Content>
</Card>
</Col>
<Col Class="basis-4/12">
test
</Col>
</Row>
Row.razor
<div class="@Class flex flex-wrap md:mx-2">
@ChildContent
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public string? Class { get; set; }
}
Col.razor
<div class="@Class @_sm @_md @_lg @_xl @_xxl basis-full mb-3 md:px-2">
@ChildContent
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
[Parameter]
public string? Class { get; set; }
private string _sm = string.Empty;
private string _md = string.Empty;
private string _lg = string.Empty;
private string _xl = string.Empty;
private string _xxl = string.Empty;
[Parameter]
public string? sm { set => _sm = $"sm:{value}"; }
[Parameter]
public string? md { set => _md = $"md:{value}"; }
[Parameter]
public string? lg { set => _lg = $"lg:{value}"; }
[Parameter]
public string? xl { set => _xl = $"xl:{value}"; }
[Parameter]
public string? xxl { set => _xxl = $"2xl:{value}"; }
}
Card.razor
<div class="@Class mb-2 bg-slate-600 dark:bg-zinc-800 text-white dark:text-gray-400">
<div class="mx-2 md:mx-5 py-3">
@* Title *@
@if (Title is not null)
{
<div class="my-2 justify-center">
<p class="text-3xl ">@Title</p>
</div>
}
@* Content *@
<div>
@Content
</div>
</div>
</div>
@code {
[Parameter]
public RenderFragment? Title { get; set; }
[Parameter]
public RenderFragment? Content { get; set; }
[Parameter]
public string? Class { get; set; }
}
Error:
Błąd (aktywny) RZ1034 Found a malformed ‘Col’ tag helper. Tag helpers must have a start and end tag or be self closing.
What did I do wrong? I was looking for a solution but unfortunately I can’t see it …
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
.net core 7 preview 2
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top GitHub Comments
Read more comments on GitHub >
Top Results From Across the Web
Error when using components in if blazor server side #7258
Is there an existing issue for this? I have searched the existing issues Describe the bug is if: not if, work: Code: Test...
Read more >Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >Blazor in MVC: Component gets rendered, but @onclick ...
The solution to the problem was changing two things: To fix the errors in the console I had to put <base href="/" />...
Read more >Blazor Best Practices: Handling Errors
Errors are likely to occur, the question is how to handle them. Let's take a look at best practices in handling them in...
Read more >My site had a malformed component error but ...
I'm currently building a website in blazor server-side framework, and I have accidentally caused blazor component malformed error.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found