Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with session state and multiple 'child' pages

Status
Not open for further replies.

mdProgrammer

Programmer
Oct 2, 2004
71
US
I have a search page in my application where the user enters one or more search options, and displays a datagrid. I put a "view detail" button which will pop up another page (using javascript) that shows a read-only version of the add/edit screen. Session("sqlDBSearch") gets a datatable with the current SQL string in the form. (for example, it may show 7 records)

Code:
Session("sqlDBSearch") = dbClass.getDataTable(SQL.tostring)
 msg.Text = "<script>window.open('default.aspx?search=readonly,'','dialogWidth:780px;dialogHeight:494px;status=no;scrollbars=no');</script>"

This opens up the readonly window fine, with a navigation control I created (first/prev/next/last). Form #1 might show "3 of 7 Records".

Here's where it goes wrong. I go back to the search form, and enter another search which displays a different result. (i.e., 2 records), and the 2nd popup form will show "2 of 2 records". The problem is that on the first popup, if I select any navigation button, it shows "2 of 2". So, the session variable is being overwritten. I also tried ViewState, which didn't work, and I don't think Application would do the trick, either. This is the code that is in my page load (inside of a if not ispostback statement) if the request.querystring "search" keyword is there.

Code:
ViewState("sqlDBSearch") = Session("sqlDBSearch")
                    populateSearchFields(ViewState("sqlDBSearch"), 0) '0 is the 1st record

Is there a way that I can keep the datatable session or viewstate unique to that page?
 
Oh, and forgot to mention - this is ASP.NET 1.1. (Long story, don't ask)
 
Viewstate is unique to the page, session is unique to the browser session. Viewstate will work, however, I don't have you code in front of me to look at. If you want to use session variables, you will have to create a unique session var for each page.
 
session is unique to the user, it is shared across all requests made by that user. so your second set of results overwrites the first.

here are the issues I see with this approach.
1. you are using session, no need for this as the data is not be to be available across requests
2. you are storing the results. no need, fetch them when you need them.
3. you are using pop ups to display the results. This seems counter intuitive to me. why not just reload the results on the same page and remove the pop up all together.

I would take this approach instead.
send the filter to the "pop up" (if you are going to use it) window using GET or POST (not session). have this page fetch the results based on the query. (no need to store the results in session).

now each pop up will manage it's own search results.

if you remove the pop up altogether this is all a mute point.

you may also want to consider a modal window rather than a popup as modals are part of the same window and cannot be stopped by pop up blockers.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
I've replaced the session("...") variables with viewstate in the data navigation page and now it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top