473,396 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Retain values between postbacks???

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)
{
...
}
}
}
Aug 29 '07 #1
2 2750
Try to use the ViewState

ViewState("name") = "value"

Bruno

"John" <Jo**@discussions.microsoft.comwrote in message
news:EE**********************************@microsof t.com...
>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)
{
...
}
}
}

Aug 29 '07 #2
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" <brunopiovan AT gmail DOT com (NOSPAM!)wrote in message
news:Ox**************@TK2MSFTNGP04.phx.gbl...
Try to use the ViewState

ViewState("name") = "value"

Bruno

"John" <Jo**@discussions.microsoft.comwrote in message
news:EE**********************************@microsof t.com...
>>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)
{
...
}
}
}


Aug 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bill Cohagan | last post by:
In my app I'm validating an XML file against an XSD which contains several attribute default value specifications. I'm performing the validation via an xml document load() using a...
2
by: theo | last post by:
Hi... I wish to extract the text content of an Xml file and assign it to DropDownList controls at runtime.I can get the Xml file text content into the DropDownList controls (Ex...if 5 Xml text...
2
by: Mark | last post by:
I'm adding several controls (labels, etc.) to a placeholder programatically. I'd like the PlaceHolder to maintain these contents during postbacks without having to programmatically recreate their...
6
by: Neil | last post by:
Hi, I have an aspx page with a number of web controls on it and one of these is a cancel button. I want to check the page to see if the user has changed any of the controls, i..e typed some text...
4
by: Pål Andreassen | last post by:
We are using a TreeView defined in a MasterPage for navigation. The tree holds it's state turing postbacks just fine since it's using viewstate. But whenever a node click results in a redirect to a...
3
by: Dhruba Bandopadhyay | last post by:
I am using a <asp:TextBox TextMode="Password"... etc. however it doesn't retain it's text through postbacks, whereas other textboxes do. Does anyone know how to retain the text?
4
by: Nathan Sokalski | last post by:
I have 2 private variables in my class that I need to remember the values of between postbacks (or actually callbacks, since I am using AJAX). I want to avoid using session variables, if possible....
3
by: raaman rai | last post by:
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation. When i add the information from a form, i retain the form values in the following way incase...
9
by: sweetline priya | last post by:
hi friends.. in my page the form contains 10 textboxes. the user has to fill these textfields. if the user made any mistake in entering value in any textbox, in the button click, a message is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.