Reputation: 12366
I get a userId in the Default page, where I connect to the database(Oracle if it's interesting).I want to keep this userId and use it in the pages I open. I need it to compare with a combobox SelectedItem.Value. And this combobox is found almost in all the pages in the web site.How can I send this UserId as a parameter? Or is there a place where I can keep this variable and use it when I need. I'm sure it's very common and I wonder what the common and best way is.
Upvotes: 1
Views: 124
Reputation: 52241
You can send it as a querystring parameter
, but the best way to keep the value in memory is with a session variable
Upvotes: 1
Reputation: 3412
As others said you can store variables in Session. But if you want to save information about user "Microsoft way", best is to implement MembershipUser and MembershipProvider classes.
Upvotes: 1
Reputation: 15571
There are multiple ways:
One, you can simply put it in the session and use it everywhere for the user session.
Second, you can pass it explicitly using a post or querystring. Using this option will need you to specify it all redirections.
Upvotes: 1
Reputation: 7601
Check the tutorial on msdn
How to Pass Values Between ASP.NET Web Pages
Upvotes: 1
Reputation: 2571
If you're needing it in (almost) every page, I think Session
would be a good place to put the variable.
Upvotes: 1
Reputation: 19862
Have a look @
ASP.NET State Management Overview
AND
ASP.NET State Management Recommendations
Upvotes: 2
Reputation: 460158
The Session would be a good place for a variable like a UserID.
Upvotes: 1