Marius Vasile

Marius Vasile

  • 1.1k
  • 1.1k
  • 35.3k

asp.net core verify a model is not null before jquery

Nov 27 2021 9:15 PM

I have a query to be executed on a btn click. The problem is that I can't even open the page because the model is null which I know it is innitialy but becomes not null based on a parameter passed later. What I tried is

$(function(){
                $("#btnVer").on("click", function(){
                    if("@(Model.IntrebareClass != null)")
                    {
                        //checkA
                        if($("#rasA").hasClass("colorA") && checkA == "@Model.IntrebareClass.CorectA")
                        {
                            $("#rasA").css("background-color", "green")
                        }

this is a part of the jquery. How do I fix this?


Answers (7)