Issues with DataAnnotationsValidator and ValidationSummary
I am currently following a tutorial to learn Blazor (I'm working in 8.0).
I have a
MessageWall.razor
file, containing:
and a MessageModel.cs
(contained within a Models
folder, which I added to @_Imports.razor
using @using BlazorServerMessageWall.Models
):
When I fire up the application, and enter a valid entry (eg; "hello", "123456") I get the attached image [posted below]. Really baffled here, read through the documentation. What am I doing incorrectly?25 Replies
@Rusty Shakleford I can't find the image (maybe you forgot to add it)
Oh! I attached it but it seems to have not uploaded. Hopefully it's attached here 🤞
@Rusty Shakleford, what is the .NET version you are using?
8.0
After .NET 8 somethings where changed about Blazor in the latest versions,
for example you now can declare the rendering logic per page like:
Sadly that doesn't seem to have worked either! I wonder if I just created the wrong type of project on creation... I'm completely new to the whole .NET arena and the tutorial I'm following is a little out of date
Right. Can show how your App.razor or host.cshtml looks like? Either one you have
This is my App.razor:
and your program.cs ends like this?
Yep!
it got to be something somewhere else then
your code, with the addition of InteractiveServer seems right
I'm heavily starting to suspect I selected the wrong Blazor project type! I really don't understand all the different ones yet (I started this morning 😅 ), there were two (that I saw) that I could select. One was WebAssembly Standalone, and the other was Blazor Web App. I selected the Blazor Web App
here's the one i choosed
I just downloaded the completed code from the tutorial, and it prompted me to install .NET 6... which has now given me another project type - Blazor Server App
Could it be my file structure? I've got it set up like this...
(whoops, MessageWall.razor is in the Pages folder, I forgot to un-collapse it for the screenshot)
yea same here, try creating a bew Blazor Web App from visual studio interface
then you just paste what you typed in here
and test if it works
all you should need is this
uncheck sample pages (if you are not interested in the template)
otherwise it will pollute your project with more files
How strange.... It works when I make a new application like you said!
Even though there's no difference between the old one, and the new one!
I would compare all files from both just to make sure
There got to be something that screwing things up
code cop investigation XD
The only difference I can think of, is that in the old application, I deleted the Counter and Weather Pages... And commented out the links to them in the NavMenu
There are a lot of times where we are sure that things are the same, feels like a phantasmagoric effect.
The bug is usually where you where most sure everything seemed right
Happens everytime with everyone, anyway, happy coding!
Deeply frustrating stuff! I've just moved over from predominantly making my web stuff in either JS or Python, so this is an experience so far 😂 Thank you so much for your help!