❔ Help needed to fix ASP.NET syntax errors
Hi all, I'm currently doing a project for ecommerce site, and have encountered multiple bugs while debugging and have been stuck on it as i'm not sure how to fix them.
The issue is with the check out page, the quantity toggle buttons work ok but the trash can to delete each row and 'remove all' button which deletes everything in the cart at the top doesnt work. when i tried debugging, these are the errors shown (Apologies if context is not set very clear as i am super new to ASP.NET):
The issue is with the check out page, the quantity toggle buttons work ok but the trash can to delete each row and 'remove all' button which deletes everything in the cart at the top doesnt work. when i tried debugging, these are the errors shown (Apologies if context is not set very clear as i am super new to ASP.NET):
3 Replies
Here's my code in the js file:
Some snippets of the cshtml file:
Any help would be really appreciated. Thanks!
Been ages since I used jQuery, but isn't the error message obvious?
carts
does not exist
this is C# code
JS has no access to it whatsoever
It runs only ever on the server side and then disappears
A quick and dirty solution would be
before you include the script that uses the carts
variable
Now, that is of course assuming ViewBag.Carts
can be turned into a sane string
It might as well return a System.Collections.Generic.Dictionary<System.String, System.Object>
So you might want to look into serializing it to JSON
(also might want to look into not using ViewBag
)Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.