I am working on a ASP.NET Blazor and C# project. In this project, I have several long form sections. My plan is to have an image change when all of the inputs in a form section are completed. The image will probably just be a green checkmark to show that the user has completed he form section. Here is my code:
void ValidFormSubmitted(EditContext editContext)
{
<img src="images/approval-16.ico" alt="Image">
}
void InvalidFormSubmitted(EditContext editContext)
{
<img src="images/approval-16-grey.ico" alt="Image">
}
}
When I run it just like this, I get error cs0103 “the name ‘_builder’ does not exist in the current context” in reference to this:
#nullable disable
__builder.AddMarkupContent(0, " <img src="images/approval-16.ico" alt="Image">rn");
#nullable restore
#line 521 "C:UsersBrycemanDocumentsGitHubSLC.gitSLC_RoadSLC_Road_Dumping_Web_AppPagesStatisticsStatisticsEntry.razor"
}
void InvalidFormSubmitted(EditContext editContext)
{
#line default
#line hidden
#nullable disable
__builder.AddMarkupContent(1, " <img src="images/approval-16-grey.ico" alt="Image">rn");
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There are many ways this can be achieved, one quick way is that you can have some flags in the form of properties in the page as following:
public bool IsStepOneSuccess { get; set; }
public bool IsStepTwoSuccess { get; set; }
public bool IsStepThreeSuccess { get; set; }
And you can raise these flags as true when your steps are passed.
... // some code to validate step 1 IsStepOneSuccess = true; ... // some other code
And in your razor page you will have the following:
@if (IsStepOneSuccess)
{
<img src="images/approval-16.ico" alt="Image">
}
else
{
<img src="images/approval-16-grey.ico" alt="Image">
}
Method 2
It seems like a bug in the asp.net core framework.
https://github.com/dotnet/aspnetcore/issues/13275
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0