Retain values between postbacks???

  • Thread starter Thread starter Guest
  • Start date Start date
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)
{
...
}
}
}
 
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
 
Back
Top