title: How to pass the session value declared in the Controller to jquery variable?
body: <p>I have created a function in controller in which I have created three sessions and passed the values. I need to pass the values to some variables in jquery file to use it in a function.
  Here is the controller function</p>
  
  <pre><code>public string GetAssociatedCompSetsForGroup(string groupID, string ScreenName)
      {
          Session["WorkBookID"] = Session["workbookId"];
          Session["groupID"] =  groupID;
          Session["ScreenName"] = ScreenName;
          IList&lt;int&gt; compSetsIds = serviceKMALocator.InvokeService&lt;IList&lt;int&gt;&gt;(x =&gt; x.GetAssociatedCompSetsForGroup(Convert.ToInt32(groupID), ScreenName));
          string ids = string.Empty;
          foreach (int id in compSetsIds)
          {
              ids = ids + id.ToString() + Constant.SemiColon;
          }
          if (!string.IsNullOrEmpty(ids))
          {
              ids = ids.Substring(0, ids.Length - 1);
          }
          ViewBag.CompSetIds = ids;
          Session[Constant.CompSetIds] = compSetsIds;
          return ids;
      }
  </code></pre>
  
  <p>and the values of three sessions i have created in the controller should be passed to the variables in the following code and i have tried something like this. </p>
  
  <pre><code> var GroupID = '&lt;%=Session("groupID")%&gt;';
  var WorkBookID = '&lt;%=Session("WorkBookID")%&gt;';
  var ScreenName = '&lt;%=Session("ScreenName")&gt;';
  
  
  if (GroupID != null &amp;&amp; WorkBookID != null &amp;&amp; ScreenName != null) 
  {
  
  
      $.post(compsetForGroup, { groupID: GroupID, ScreenName: ScreenName }, function (jsonData) {
          if (jsonData) {
              function ajaxCall(no) { .....
  </code></pre>
  
  <p>Please help me with the correct format. Thankyou in advance.</p>