ā MVC - data is being passed to view, but not displayed
My app worked fine earlier and somehow I broke it, and I do not know how.
My model is full of data, and by putting a breakpoint in the razor code I can see that it is being passed to the view as well. However, once the view is rendered, the data is not there. See the total property in the screenshots below.
To further confuse things, this is only happening when using lambda expressions. I put a
<span>@Model.Total</span>
line in just to test, and it is displaying the data in the view.
Any ideas? Clearly I broke something but I have no idea what I did.17 Replies
And like a fool I just realized I posted this in the C# discord, but it's VB code... but I mean, it's the same aside from some slight syntax differences, and I don't think there's a large VB discord community that can help. Hope it's OK.
What actual HTML does it generate?
And yeah, you're right, there won't be many places where you can get help with dead languages
here's the html
VB might be "dead" but unfortunately it is alive and well in legacy codebases, thankfully it correlates 1-to-1 with C# so you can just write in C# and run it through a translator if you want lol
I guess, yeah, it would be 1-to-1 with some ancient version of C#
you'd be surprised, it was actively supported until very recently I think
IIRC it had a complete feature freeze for years now, just security fixes
What if you remove this whole thing?
Also, odd that it would use
type="text"
instead of type="number"
for what looks like a floatsame result, it just messed the css up
the equivalent of that line in C# would be
Html.EditorFor(model => model.Total, new { htmlAttributes = new { class = "form-control" } });
in case that's unclearMaybe try that
htmlAttributes:=
thing you have for label?
Not sure tbh, everything looks correct to me
That said, I don't know much about legacy MVC or about VB, so maybe one of the graybeards in the server will spot an obvious error I can'tit's just weird because the breakpoint shows that the data is there, but once the view is rendered, it's MIA
š¤·āāļø
I'm happy to blame vb lol
Here's a weird behaviour... I manually punched in some value for the total, and it is displaying correctly in both the input and my little test <span> element
and if I call the HttpPost actionresult, it is only updating the <span>, not the input
I fixed it by rolling back my changes this afternoon, no idea what the problem was.
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.