Hello,
In my MVC application I have a function to read the column names and store it in a session array. Below is the code which I used.
public void SetViewBag(int id)
{
try
{
connection();
SqlCommand cmd = new SqlCommand("obps_sp_getColDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
List<string> colname = new List<string>(250);
while (rdr.Read())
{
colname.Add(rdr[0].ToString());
}
Session["colname"] = colname;
}
finally
{
con.Close();
con.Dispose();
}
}
This session values are accessed from a view page using the code which shown in the image attached.

Now I want to remove this from the view page and add this function in a seperate javascript file.
But when I used the function Test same like this in the js file, it is throughing error.
Can some please help me to find a way to read the session array inside a javascript file.