2

I have c# variable check that I want to use in my jquery if condition. But I am getting error

Uncaught ReferenceError: DGSCRM is not defined

where DGSCRM is the value present in my c# variable check.

@{
    string check = Model.ChangeAddress.ControllerName;
}
<script type=text/javascript>
    $(document).ready(function () 
    {
    if(@check == "DGSCRMAPI")
    {
        $('#logo').hide();
    }
});

</script>

Is it the right approach to mix c# and jquery code in views?

1

1 Answer 1

8

you need to wrap in "

if("@check" == "DGSCRMAPI")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.