Click here to Skip to main content
15,887,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have a error in my .cshtml but can't find a reason why it is complaining about a invalid character.

I have a inline script section. see below:

JavaScript
}
<script>
    function setBanner(bool){
        if (bool == 'true')
        {
            $('.banner').attr('data', 'false');
            $('.Priority-control').attr('value', false);
            $('#image-source').attr('src', '/Content/images/Banner-laag.png');
        } else {
            $('.banner').attr('data', 'true');
            $('.Priority-control').attr('value', true);
            $('#image-source').attr('src', '/Content/images/Banner-important.png');
        }
    };
</script>

@Html.HiddenFor(m => m.FollowupId)


Before the closing tag it tells me I have a invalid character
'invalid character' </script>

I have 5 script sections. 3 of them are saying 'invalid character' in front of the closing tag of the script section.

Anyone who have a solution to fix this problem?
Removing and retype solves it till closing and reopening the document.

Potential fixes from 'Quick actions and refactoring' only gives the option to remove script section.

Update:
I runned jslint
It is saying:

JavaScript
Expected '/'.
                    </script>

Can't see why...

What I have tried:

- Potential fixes from 'Quick actions and refactoring'
- Removing and retype script sections.
- combining all sections to one script section.
- restarting visual studio 2015.
- clean/ rebuild

- replacing qoute for double qoute.
- removing end tag {
- removing ;
Posted
Updated 9-Nov-16 1:16am
v2
Comments
Karthik_Mahalingam 9-Nov-16 5:37am    
try removing the '}' above script block
Wessel Beulink 9-Nov-16 5:41am    
Also didn't work out. I found a site JSlint I runned the code analyse. telling me Expected '/'.


Don't see why.
Karthik_Mahalingam 9-Nov-16 7:57am    
ok good

Delete the semi-colon after the curly brace
 
Share this answer
 
Comments
Wessel Beulink 9-Nov-16 5:31am    
Didn't solve it unfortunately. Also the chrome developer tools is not complaining. It's visual studio only.
Removed all script sections to a .js file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900