1

i have a website a with some textfields.

website b is in the iframe of a.

I saved in website b some values in different sessions

  Session("anzahlInterneTeilnehmer") = anzahlInterneTeilnehmer
  Session("anzahlExterneTeilnehmer") = anzahlExterneTeilnehmer

after i saved the sessions i call the parent function from website a

parent.parentTeilnehmer()

i want to display the session values in the textfields of website a

            function parentTeilnehmer() {
            var intern = ????
            var extern = ????
            var InterneTextFeld = ISGetObject("WebInput1");
            var ExterneTextFeld = ISGetObject("WebInput2");
            InterneTextFeld.SetValueData(intern);
            ExterneTextFeld.SetValueData(extern);
        }

how can i do that without refreshing the whole page?

2

3 Answers 3

4

Session is stored server side so you cannot access these variables clientside via javascript. I suggest saving these variables to a hidden field

<input type="hidden" id="anzahlInterneTeilnehmer" runat="server" />
<input type="hidden" id="anzahlExterneTeilnehmer" runat="server" />

Attach an event handler to the Website A's page PreRender method and in there set the anzahlInterneTeilnehmer's value to the session value (excuse my VB)

Private Sub Page_Render(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.PreRender
anzahlInterneTeilnehmer.Value = Session("anzahlInterneTeilnehmer")
End Sub

Then in your javascript

var internHolder = document.getElementById("anzahlInterneTeilnehmer");
var intern = internHolder.value;
Sign up to request clarification or add additional context in comments.

Comments

3

You can do like this in javascript

var val = <%= Session["MyVariable"]%>; 

Comments

1

You can access Session variables in javascript only if your js function is present on .aspx page which is not a good approach as it is better to keep our script files in separate Scripts folder so you can store session values in hidden fields:

<script type="text/javascript">
    function GetSessionValues() {
        var intern = '<%=Session("InternalValue") %>';
        var extern = '<%=Session("ExternalValue") %>';
    }
</script>

1 Comment

It works for me if I set Session("InternalValue") and Session("ExternalValue") at Page_Load event, how you do that ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.