AnsweredAssumed Answered

Accessing Session Variables in .JS page

Question asked by jay.kapalczynski on Aug 19, 2014
Latest reply on Aug 20, 2014 by jay.kapalczynski

Accessing Session Variables in .JS page

 

I have my Session variable accessible at the .ASPX page....

But I also have a .JS page that is defining the map and layers to render.

 

I need to get the session variable in the .JS page....cant figure out how to...

 

Anyone have any thoughts?

 

I am trying to get the value of the Hidden Input type in .JS page like this

 

IN .JS PAGE

var varToken = registry.byId("tokentext");

alert(varToken);

 

 

In the .aspx page and .aspx.vb page I can alert the Session variable as such

 

IN .NET

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

   tokentext.Value = Session("tokentext")

End Sub

 

IN .ASPX PAGE

<form id="form1" runat="server">

  <div>

   <asp:Label ID="tlabel" runat="server"></asp:Label>

  <input type="hidden" id="tokentext" name="tokentext" runat="server"/>

  <asp:Button ID="Button1" runat="server" Text="Button" style="margin-left: 55px" />

  </div>

 

  <script type="text/javascript">

        var tvalue = document.getElementById('<%= tokentext.ClientID%>').value

        alert(tvalue);

  </script>

</form>

Outcomes