473,466 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Label retains old text...

Hey all,

I have a label that gets its text from a DB. This text can be changed
on the page in a textbox and after the save button is clicked the new
text is updated in the DB and the page refreshes.

The problem: Even though in the page_load method the label's text is
being set to what is in the DB the text is still the old text. If u
refresh the page the text then updates. Why is this happening? The
label's viewstate is false and if I create a method that does the
exact same thing as page load it works for some of the labels (this
is affect all labels that get updated) but not for others.

Any ideas?

Thanks.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 18 '05 #1
1 1212
The Save button's click event is called after Page_Load.

Therefore you are probably setting the label text from the database, then
updating the database. This is the wrong order for what you need and that's
why the page displays improperly.
Perhaps you should re-set the label text property in the save button's click
event.

Or you could move the code that sets the label text to the Page_PreRender or
Page_Render event, both of which are called after the button click event.

If you've got the time, I suggest you study the lifecycle of pages and
controls.
Here are some good articles on the subject:
http://www.15seconds.com/issue/020102.htm
http://msdn.microsoft.com/library/de...singStages.asp
http://msdn.microsoft.com/library/de...nlifecycle.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"ProgramAnalyst" <al**********@scotiabank-dot-com.no-spam.invalid> wrote in
message news:41**********@Usenet.com...
Hey all,

I have a label that gets its text from a DB. This text can be changed
on the page in a textbox and after the save button is clicked the new
text is updated in the DB and the page refreshes.

The problem: Even though in the page_load method the label's text is
being set to what is in the DB the text is still the old text. If u
refresh the page the text then updates. Why is this happening? The
label's viewstate is false and if I create a method that does the
exact same thing as page load it works for some of the labels (this
is affect all labels that get updated) but not for others.

Any ideas?

Thanks.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 18 '05 #2

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

Similar topics

4
by: Stuart Norris | last post by:
Dear Readers, I am attempting to draw box around some text using unicode on multiline label. The label is forty characters wide and 12 lines deep. I have been trying to draw a box around text...
3
by: Dude | last post by:
Below is the code - it is finding the control, and there is no error, just not assigning the text to the label <asp:DataList id="dlGoals" runat="server" onEditCommand="myListEditHandler"...
5
by: JollyK | last post by:
Hello all, I have always been having this issue and wondering what the solution is. When I set the enableviewstate property to false for a textbox, the textbox always retains its value after a...
7
by: cFleury | last post by:
I have an ASP.NET web form that is retaining values over different stations on the network, how can I stop this behavior ?. I didn’t do anything special to cause it. Thanks C.Fleury
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
1
by: Manoj Mittal | last post by:
I have created the Dynamic control in asp.net c# like for (int i = 1; i <= 5; i++) { Label label = new Label(); label.ID = "Label" + i; label.Text = "Label"+i; form1.Controls.Add(label); }
11
by: Peter Larsen [] | last post by:
Hi, I have two questions related to the Label control. How do i prevent the label from expand the canvas into 2 lines (word wrap) ?? At the moment i set AutoSize to false (to prevent the word...
0
by: Kevin McKinley | last post by:
Below i've put the code for a program that i wrote. I need help on lines 384-403. If you run this program you will notice on the first tab when have it produce an answer the $ is surrounded with...
0
by: Guilherme Polo | last post by:
On Wed, Sep 3, 2008 at 8:57 PM, Kevin McKinley <kem1723@yahoo.comwrote: Come on.. "help on lines 384-403", that is not a good way to look for help. You are supposed to post some minimal code that...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.