On loading the page I want to pass a value to my javascript function from a server side variable.
I cannot seem to get it to work this is what I have:
Asp.Ne
What I've done in the past is what webforms does as it's functionality--creating a hidden field to store values needed by the client. If you're using 4.0, you can set the hidden field client id mode to static to help keep things cleaner as well. Basically, add you value to the hidden field and then from javascript you can get the value or modify it too(in case you want to pass it back) since it's just a dom element.
If you really want to use code--like a variable, it needs to be accessible at the class scope.