Retain values between postbacks???

G

Guest

I have a MyUser class containing user profiles. Everytime after postback, I
have to reload (access the database) again. Is there any way I can easily
save those data between postbacks? Thanks.

public partial class Login : System.Web.UI.Page
{
MyUser m_MyUser = new MyUser();
...
m_MyUser.LoadDetails(UserID);
...
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
...
}
}
}
 
B

BillE

Use session variables carefully.

If the same web application is opened in multiple tabs in IE7, the session
is shared between the tabs. Each tab does not have its own set of session
variables. This can lead to complications, like placing an order for the
wrong customer.

Bill

Eliyahu Goldin said:
It depends on the amount of data. ViewState travels with the page to
client and back. Session variables remain on the server. They are more
commonly used for keeping data.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Bruno Piovan said:
Try to use the ViewState

ViewState("name") = "value"

Bruno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top