When my page loads, it stores the identifier from the database in the session: Session["AppId"] = 1234 . However, when I do JavaScript, I need to know what AppId is for database calls. How can I make this available to my JS from server code? Will the script tag be logged with var appId = 1234 , or will this code dry out a bit?
Would adding a custom attribute to the body tag make more sense? data-appid=1234 for example?
I am new to web content, so do it and itβs not always obvious to me. If there is a right / best way, feel free to share it.
EDIT:
I really needed a solution HttpContext.Current.Session["AppId"] . I did not think that static methods could access session values, so I thought that I needed to save them in a method in order to go to my WebMethod through an Ajax call. I accepted the answer I made because he answered the question I asked. I just asked the wrong question. =) I'm new, I remember - come on me!
source share