• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

asp.net question

Bigbacon

Fully [H]
2FA
Joined
Jul 12, 2007
Messages
22,555
Just curious what you guys thnk is the easiest and best way to pass variables from one page to another, both client side and server side and then get back to the parent page and make sure it's still the way it was.

So say I have a page with a check box and a button.

I press button, goes to new page and page says is check is checked or not and there is a close button. I click close, goes back to the first page and the checkbox is back at whatever state it was originally in.

Does that make sense?

Thats a rather simple interpretation but my thought was some kind of object that stored things like the checkbox's state and plop the object into a session (or something similar) then I could use web service to access the object in the session and get/set values either through javascript or server side code.

First page can then just reaccess the object to get the state info back.

or can you just store the view state and reload it somehow.? hmm. Thoughts?
 
ViewState and Session are two viable options, where you would store a simple datatype indicating the resulting value from the first page. Request.Form can also be used within scope of the HttpContext object (one example).

One side note: If you're deploying the web app to a farm/cluster, then don't use Session.
 
ViewState and Session are two viable options, where you would store a simple datatype indicating the resulting value from the first page. Request.Form can also be used within scope of the HttpContext object (one example).

One side note: If you're deploying the web app to a farm/cluster, then don't use Session.

Certainly on the sessions. I would rather avoid them because of them expiring on users. I'll check out that link.
 
Are you using server-side code to move between pages? Are you opening page2 in the same browser window?

I am trying to do this in the same browser window.

Either way will work (I think) if the page is directed by the client or the server to the next page.

I was messing with server.transfer but that just causes odd issues when I need to go back so I am trying to avoid it unless there is something I dont know.
 
I was messing with server.transfer but that just causes odd issues when I need to go back so I am trying to avoid it unless there is something I dont know.
It has to do with the difference between Server.Transfer and Response.Redirect, such as control accessing and data hops. Some info on Response.Redirect versus Server.Transfer. From what little has been said on the application design/purpose, Response.Redirect may be a better approach, just know that you have to go through an extra step to access the form from the previous page (Request.Form.Get, for example).

After thought: ASP.Net provides an interesting control called the Wizard control. This might save some headaches if you're design is closer to a series of page "steps" for data capturing.
 
Depending on how secure you need the data to be, you could use a query string. If you use a query string, you should also have a hash of some kind with it so the users can't change data to invalid things by messing with the url.
 
You have three easy options: session state, query string and cookies. Another option may be hitting the database and storing the state, but probably not worth it.

I would go with session state and try to keep the object small. If the object becomes too large, then you may have the option of database or asp.net caching.

View state is not an option when you go from one page to another.
 
Back
Top