3
I manage to fix it by using a JSON call
- $.getJSON(`?handler=CorrectDetails&id=${id}`, (data) => {
- if (!jQuery.isEmptyObject(data)) {
-
-
- if($("#rasA").hasClass("colorA") && checkA == data.corectA)
- {
- $("#rasA").css("background-color", "green");
- }
- else if($("#rasA").hasClass("colorA") && checkA != data.corectA)
- {
- $("#rasA").css("background-color", "red");
- }
- else if($("#rasA").hasClass("colorB") && checkA == data.corectA)
- {
- $("#rasA").css("background-color", "gray");
- }
2
what if you check with boolean
- if($("#rasA").hasClass("colorA") && checkA == Boolean("@Model.IntrebareClass.CorectA") )
2
Also, the error is on line
- if($("#rasA").hasClass("colorA") && checkA == "@Model.IntrebareClass.CorectA")
checkA was assigned true value with
and Model.Intrebare.CorectA is the result of a checkbox, true or false
2
Thank you all for answers, I am using Asp.Net Core Razor pages, my jquery is in the View. I tried both solutions, Satya and Sachin but is not working. The page is loading perfectly without this function but is not working because of the model is null.
I don't see how to use model validation Srinivasan, I am not having issues in code behind
2
Use modelstate.isvalid
Check this link
https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-6.0