Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 790499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:41:30+00:00 2026-05-14T21:41:30+00:00

I load a js variable like this: var message = ‘<%= CAnunturi.CPLATA_RAMBURS_INFO %>’; where

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:41:31+00:00Added an answer on May 14, 2026 at 9:41 pm

    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:

    var message = '<%= AntiXss.JavaScriptEncode(CAnunturi.CPLATA_RAMBURS_INFO) %>';
    

    EDIT: If AntiXss doesn’t help, try the following function:

    public static void QuoteString(this string value, StringBuilder b) {
        if (String.IsNullOrEmpty(value))
            return "";
    
        var b = new StringBuilder();
        int startIndex = 0;
        int count = 0;
        for (int i = 0; i < value.Length; i++) {
            char c = value[i];
    
            // Append the unhandled characters (that do not require special treament)
            // to the string builder when special characters are detected.
            if (c == '\r' || c == '\t' || c == '\"' || c == '\'' || c == '<' || c == '>' ||
                c == '\\' || c == '\n' || c == '\b' || c == '\f' || c < ' ') {
                if (b == null) {
                    b = new StringBuilder(value.Length + 5);
                }
    
                if (count > 0) {
                    b.Append(value, startIndex, count);
                }
    
                startIndex = i + 1;
                count = 0;
            }
    
            switch (c) {
                case '\r':
                    b.Append("\\r");
                    break;
                case '\t':
                    b.Append("\\t");
                    break;
                case '\"':
                    b.Append("\\\"");
                    break;
                case '\\':
                    b.Append("\\\\");
                    break;
                case '\n':
                    b.Append("\\n");
                    break;
                case '\b':
                    b.Append("\\b");
                    break;
                case '\f':
                    b.Append("\\f");
                    break;
                case '\'':
                case '>':
                case '<':
                    AppendCharAsUnicode(b, c);
                    break;
                default:
                    if (c < ' ') {
                        AppendCharAsUnicode(b, c);
                    } else {
                        count++;
                    }
                    break;
            }
        }
    
        if (b == null) {
            b.Append(value);
        }
    
        if (count > 0) {
            b.Append(value, startIndex, count);
        }
    
        return b.ToString();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class level price variable decalred inside a page, like this: public
this is my demo code : <body onload=initialize()> <script> function initialize(){ var d='adddd' $.getScript('other.js',
Hay, i have a flash movie which loads a static XML file, the script
I am trying to set a javascript variable to be one of a few
Me again. The sliding in works like a charm. But I want to extend
I need to pre-load some values from a php script, I'm using a $.post
My markup is a simple div element with id 'load'. Using jQuery I then
I'm trying to install django lfc on my server. Apart of zilions of different
I have information (20,000 frames of data) about an audio track that I have
For some years that I've been using my own PHP template engine, which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.