Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use @ in script code in MVC [duplicate]

Possible Duplicate:
Escape @ character in razor view engine

how can i use '@' symbol in my script code in the MVC page (razor engine)

write a code like this :

<script>
var a = "this is a test text with @ symbol";

alert(a);
</script>
like image 663
MHF Avatar asked Dec 13 '22 03:12

MHF


2 Answers

You can escape by use of two ampersat symbols: @@.

var a = "this is a test text with @@ symbol";

As an aside, though I recently learned and think those coming across this question might also find it useful: you can do comments with a combination of ampersat signs and asterisks:

@*this would comment out some code, or just allow for comments in general*@
like image 200
Grant Thomas Avatar answered Feb 28 '23 11:02

Grant Thomas


@@ should work to escape the character

like image 26
Willem D'Haeseleer Avatar answered Feb 28 '23 11:02

Willem D'Haeseleer