I load a js variable like this:
var message = '<%= CAnunturi.CPLATA_RAMBURS_INFO %>';
where the static string CPLATA_RAMBURS_INFO i put like:
public static string CPLATA_RAMBURS_INFO = "test";
I use it very well in this method.
<script type="text/javascript">
var categoryParam = '<%= CQueryStringParameters.CATEGORY %>';
var subcategoryParam = '<%= CQueryStringParameters.SUBCATEGORY1_ID %>';
var message = '<%= CAnunturi.CPLATA_RAMBURS_INFO %>';
function timedInfo(header) {
$.jGrowl(message, { header: header });
};
</script>
so the message appears.
I do not undersand, why, iso of “test”, if i take the value from a static method,
ths use of message js var is no longer succesfull (the message no longer appears).
public static string CPLATA_RAMBURS_INFO = getRambursInfo();
public static string getRambursInfo()
{
return System.IO.File.ReadAllText(PathsUtil.getRambursPlataFilePath());
}
EDIT:
Source Code:
<script type="text/javascript">
var categoryParam = 'category';
var subcategoryParam = 'subcategory1Id';
var message = 'Lorem ipsum dolor sit amet, eu curabitur venenatis
viverra pellentesque tortor tempor,
nam est suspendisse, aenean vestibulum,
suspendisse eget metus aenean at dictum nulla.
In luctus, neque porttitor suscipit nibh, aenean
ut, commodo velit leo volutpat ullamcorper.
‘;
function timedInfo(header) {
$.jGrowl(message, { header: header });
};
</script>
Your file contains special characters (probably a newline or a
') that cause the rendered Javascript to contain a syntax error.You need to escape the string using the Anti-XSS Toolkit, like this:
EDIT: If AntiXss doesn’t help, try the following function: