Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 457839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:36:41+00:00 2026-05-12T22:36:41+00:00

could you please clarify my issue? I have a starting page ListBox1.aspx that calls

  • 0

could you please clarify my issue?

I have a starting page ListBox1.aspx that calls another one ListBox1_sub.aspx. I need to preserve a state of the page ListBox1.aspx so that after returning from ListBox1_sub.aspx all the controls of ListBox1.aspx keep their state. I assume it could be achieved by using a client-side code and in the attached code everything looks OK except one thing.

In my code, I set the value of the Session variable Session(“back_from_ListBox1_sub”) in ListBox1_sub.aspx. After returning from ListBox1_sub.aspx to ListBox1.aspx, I expected the txtReturn TextBox to show the value of the Session variable. However, although this value was set to the text box, it was not shown.

In the below code, the value of the Session variable is displayed only after the 2nd call to ListBox1_sub.aspx. For example, if I set the value to “x” in the first call and to “y” in the second call, after returning from the 2d call the value will be set to “x”.

Can you advise as to how I should modify my code so that the returned value be displayed correctly in the first page after the call to the second page?
Many Thanks,
Lev

======= test code =======
== ListBox1.aspx =====

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ListBox1.aspx.vb" Inherits="ListBox1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:CheckBoxList ID="CheckBoxList1" runat=server Visible="True">
    <asp:ListItem Text="a" />
    <asp:ListItem Text="b" />
    <asp:ListItem Text="c" />
    <asp:ListItem Text="d" />
    </asp:CheckBoxList>
     <br />
    <asp:LinkButton ID="lnkWindowOpen" runat="server" Text="Window.Open">
    </asp:LinkButton>
    <br />
    <asp:TextBox ID="txtReturn" runat="server">
    </asp:TextBox>
    </div>
    </form>
</body>
</html>

‘code-behind

Partial Class ListBox1
    Inherits System.Web.UI.Page

    Public Const JS_START As String = "<script language=javascript>"
    Public Const JS_END As String = "</script>"
    Public Const DBQT As Char = Chr(34)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not (Session("back_from_ListBox1_sub") Is Nothing) Then
            txtReturn.Text = Session("back_from_ListBox1_sub").ToString
        End If
    End Sub

    Protected Sub lnkWindowOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkWindowOpen.Click
        Dim message As String
        Dim script As String
        message = ""
        message += "window.blur();"
        message += "window.open(" & DBQT & "ListBox1_sub.aspx" & DBQT & ",null,"
        message += DBQT & "height=200,width=400,top=300,left=325,"
        message += "status=yes,toolbar=no,titlebar=0,menubar=no,location=no,scrollbars=0,resizable=0;modal=yes" & DBQT & ");"
        script = JS_START & message & JS_END
        ClientScript.RegisterClientScriptBlock(Page.GetType, Guid.NewGuid().ToString(), script)
    End Sub

End Class

======== page ListBox1_sub.aspx ==========

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ListBox1_sub.aspx.vb" Inherits="ListBox1_sub" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
    <asp:ListItem Text="x" />
    <asp:ListItem Text="y" />
    <asp:ListItem Text="z" />
    </asp:ListBox>
    <br />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <br />
    <asp:LinkButton ID="lnkBack" runat="server">Back</asp:LinkButton>
    </div>
    </form>
</body>
</html>

‘code-behind

Partial Class ListBox1_sub
    Inherits System.Web.UI.Page

    Public Const JS_START As String = "<script language=javascript>"
    Public Const JS_END As String = "</script>"
    Public Const DBQT As Char = Chr(34)

    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        TextBox1.Text = ListBox1.SelectedItem.Text
    End Sub

    Protected Sub lnkBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkBack.Click
        Dim message As String
        Dim script As String
        Session("back_from_ListBox1_sub") = TextBox1.Text
        message = "window.close();"
        script = JS_START & message & JS_END
        ClientScript.RegisterClientScriptBlock(Page.GetType, Guid.NewGuid().ToString(), script)
    End Sub

End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:36:41+00:00Added an answer on May 12, 2026 at 10:36 pm

    The reason your value isn’t showing is because the page that opens the pop-up isn’t refreshing to show the new value.

    In your lnkBack_Click try setting message to this.

    message = "window.close();"
    message += "if (window.opener && !window.opener.closed) {"
    message += "    window.opener.location.reload();"
    message += "}" 
    

    This will close the pop-up and tell the first page to reload.

    EDIT: Update the field with javascript instead of re-loading

    What we will do is pass the id of the field we want to update to the popup. When the user clicks the button we find the field on the opening page and update it. We no longer need to use session to pass the values. I am not at a PC where I can test the code, so it might not work as is. I don’t do any error checking, you will want to add this.

    Partial Class ListBox1
    Inherits System.Web.UI.Page

    Public Const JS_START As String = "<script language=javascript>"
    Public Const JS_END As String = "</script>"
    Public Const DBQT As Char = Chr(34)
    
    Protected Sub lnkWindowOpen_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkWindowOpen.Click
        Dim message As String
        Dim script As String
        message = ""
        message += "window.blur();"
        message += "window.open(" & DBQT & "ListBox1_sub.aspx?ctrl=" & txtReturn.ClientId & DBQT & ",null,"
        message += DBQT & "height=200,width=400,top=300,left=325,"
        message += "status=yes,toolbar=no,titlebar=0,menubar=no,location=no,scrollbars=0,resizable=0;modal=yes" & DBQT & ");"
        script = JS_START & message & JS_END
        ClientScript.RegisterClientScriptBlock(Page.GetType, Guid.NewGuid().ToString(), script)
    End Sub
    

    End Class

    Partial Class ListBox1_sub
    Inherits System.Web.UI.Page

    Public Const JS_START As String = "<script language=javascript>"
    Public Const JS_END As String = "</script>"
    Public Const DBQT As Char = Chr(34)
    
    Protected Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        TextBox1.Text = ListBox1.SelectedItem.Text
    End Sub
    
    Protected Sub lnkBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkBack.Click
        Dim message As String
        Dim script As String
        message = "window.close();"
        message += "var ctrl = window.opener.document.getElementById('" & Request.QueryString("ctrl") & "');"
        message += "ctrl.value = '" & TextBox1.Text.Replace("'", "\'") & "';";
        script = JS_START & message & JS_END
        ClientScript.RegisterClientScriptBlock(Page.GetType, Guid.NewGuid().ToString(), script)
    End Sub
    

    End Class

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could somebody please tell me what is Memory Page Out Rate. I have seen
I have the following code, could anyone please clarify my doubt below. public static
could anyone please clarify the meaning of line generalizes the tag object's storage of
I'm not able to understand the following multi-dimensional code. Could someone please clarify me?
Could anyone please clarify for me the effect of Nginx caching image? Currently I
Could anyone please clarify the difference between continuous and discrete attributes? Thanks.
Could someone please clarify for me the semantic difference between these two: self.foo =
I've a small doubt in my mind; could anyone please clarify me is the
Could anyone please clarify the defination of attribute? for example, in the following code,
Could you please clarify for me the question asked here . Why it is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.