I have created a SCORM API for our LMS and right now I am using hard coded userID and courseID variables (variables that reference things in the database). I need to pass th
@tvanfosson's answer is how I have normally done this in the past, but was just trying to think of something a bit more elegant. Thought I'd throw this out there.
You can set up a HashTable in the codebehind and also initialize a JavaScriptSerializer
:
Protected json As New System.Web.Script.Serialization.JavaScriptSerializer
Protected jsvars As New Hashtable
Then set variables like this:
jsvars.Add("name", "value")
Then serialize the variables into JavaScript in your page:
This ensures that all variables are properly escaped and also minimizes the code if you need to work with a lot of variables.