John Bustos
John Bustos

Reputation: 19574

Knowing what checkboxes were checked on a separate page

I am a complete ASP newbie working on converting over a WinForms app.

In my Winforms version, I have a main form which gets inputs from the user and has a button Select OutPut Columns.

When the user clicks on that button, a second form pops up which has a list of checkboxes that is dynamically filled based upon a DB query of all the columns that are available for the user to have in their output report.

Once the user checks all the columns they want in their report, they click a Done button which sets a List(of String) property on the main form with the columns selected and hence the program can continue with the report generation.

I'm trying to emulate that same kind of functionality in my ASP project - Based upon what I've read, it seems the Session or Cache objects are the way to go for this - My questions are:

  1. Are these the correct ways to get / store this data?
  2. Which one (session / cache) should I use given that:

    (a) The user may click that button again and I would like the program to remember what columns they already chose.

    (b) Different users may select different columns (seems Cache might not work well here for that reason - Am I right?)

  3. I would like the variables to last as long as the application is running on the user's machine, but if the user closes / re-opens the app, I would like it not to remember their previous choices.

Truly, as I said, I am a complete ASP newbie and am open to learning ANYTHING new / helpful - Any good thoughts / comments / links will be !!GREATLY!! appreciated!

Thanks!!

EDIT:

As an additional question, if Session / Cache are used, is it commonplace to delete these variables on application start to ensure fresh data or is this usually not done?

Upvotes: 3

Views: 80

Answers (2)

Aristos
Aristos

Reputation: 66641

In my Winforms version, I have a main form which gets inputs from the user and has a button Select OutPut Columns.

When the user clicks on that button, a second form pops up which has a list of checkboxes that is dynamically filled based upon a DB query of all the columns that are available for the user to have in their output report.

This is the way on the windorms, now if you make a web interface is better to work as web page do, the most simple way1 - and whats that ? avoid pop ups, and use post to the next (or to the same) page.

So you have a page that the user select something, post on server, creates the checkboxes on the same page and wait for the second user input. After that final input, again a post to the same page and now you have all your user input in the page to make your output.

No dialogs, no other memory, the post are done on the same page, and the post keep the user input.

1(not jQuery dialogs and ajax call for the start)

Upvotes: 1

Katie Kilian
Katie Kilian

Reputation: 6983

You want to use the Session object. It is different for every user, and it expires after the user hasn't been seen for awhile (actual expiration time and behavior is configurable). The Session is stored on the user's web browser as a cookie identifier. If the user closes the browser, the cookie will be deleted, and they will get a new session the next time they connect to the web server. The old session will eventually time out.

Upvotes: 2

Related Questions