Skip to content Skip to sidebar Skip to footer

Load Javascript Code After Loading Code Behind

I have a web site released at facebook platform, i am using C# .Net 2008, the problem is that i am loading an array elements from code behind in javascript arary and i am loading e

Solution 1:

If the IntializeArr() function is not being called, it is most likely a javascript error in the page, and most likely caused by some invalid javascript characters in the ListofT or ListofB arrays.

You should be escaping any single quotes or newlines.

Easiest way to check is to just "view source" in the browser once the page has loaded. Look down to your script and find what values were put it and you should see if there were any errors.


Solution 2:

Maybe ListofWords[0] contains an apostrophe?


Solution 3:

Are you outputting the JS array creation to the page inside <script> tags?

You have to emit that javascript so that the browser can run it - then ArList will be available on the page to other javascript.


Solution 4:

Agree, more code example is needed.

Usually I solve something like this by using Sys.Application.add_init() or $(document).ready(). However there are other possible solutions. Use an AJAX request to get the array. Or something like:

function setInnerHtml() {
    if (typeof(ArList) != "undefined") {
        document.getElementById("WordDiv").innerHTML = ArList[0];
    } else {
        setTimeout("setInnerHtml()", 40);
    }
}

Post a Comment for "Load Javascript Code After Loading Code Behind"