cringwall
Posts: 11
|
| Posted: 08/29/2005, 12:34 PM |
|
I want to have a label control in a record form that is empty on inital page load, but is given a value upon a record update. I've tried using several of the events, AfterUpdate, etc. to no avial.
What approach would work?
This is the code I tried:
Function Employees_AfterUpdate(Sender) 'Employees_AfterUpdate @2-A4196A7B
'Custom Code @15-73254650
' -------------------------
Employees.Label1.Value= "Password Changed"
' -------------------------
'End Custom Code
End Function 'Close Employees_AfterUpdate @2-54C34B28
|
 |
 |
peterr
Posts: 5971
|
| Posted: 08/29/2005, 1:35 PM |
|
You cannot. A label is just a text displayed on the screen, so it is not submitted anywhere. There is no way to do anything with labels except outputting some text or HTML to the page.
You can use Hidden control to assign values, or use Custom Update property where you can specify that you want to assign a value/expression to a field.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
DonB
|
| Posted: 08/29/2005, 5:31 PM |
|
It's important to understand the 'flow' of data between your server and your
browser. Then you will see why it's a problem to do what you described.
There are solutions to the problem, however.
Let's say you have a page visible in the browser. You fill in some fields
and send the entire page (i.e., you submit the <form> contents) back to the
server. The page you were looking at no longer exists. The server
receives your form data and stuffs it into the database. It then send s a
NEW copy of the form back to your browser (at least, that's the default
behavior). Because this is a new page, the Label value you try to set (in
the After Update event) 'goes away', ceases to exist, and a new (empty)
label appears on the screen. It's empty, of course.
So, no matter how you try to bridge between doing the update and displaying
this label with a 'record updated' message, it will fail to display
anything. That's the nature of web programming. It's not anything specific
(or deficient) in CodeCharge.
Now, back to the 'default behavior' I mentioned. Simply put, you can alter
what page the Update sends you back to. This page can be a simple one that
merely says "record was updated, click to continue". This gets you what you
want, more or less. But it means a new (intermediate) page has to be
created, the 'update' button must specify this page as it's return page, and
the link on that new page has to point back to the first page.
You can get fancier, perhaps setting a session variable in the After Update
event, then loading this variable's value into your label on the update
form, but since session variables live as long as the session that creates
them, you also have to remember to erase the variable's value (perhaps in
the Page Unload event) or it will continue to be displayed - even when a
record hasn't been updated.
As you've probably seen on commercial websites, when you purchase something
you get a 'confirmation screen' after placing your order, then you get sent
back to the 'continue shopping' page. That's why they do that.
--
DonB
http://www.gotodon.com/ccbth
"cringwall" <cringwall@forum.codecharge> wrote in message
news:643136347a0074@news.codecharge.com...
> I want to have a label control in a record form that is empty on inital
page
> load, but is given a value upon a record update. I've tried using
several of
> the events, AfterUpdate, etc. to no avial.
>
> What approach would work?
>
> This is the code I tried:
>
> Function Employees_AfterUpdate(Sender) 'Employees_AfterUpdate @2-A4196A7B
>
> 'Custom Code @15-73254650
> ' -------------------------
> Employees.Label1.Value= "Password Changed"
>
> ' -------------------------
> 'End Custom Code
>
> End Function 'Close Employees_AfterUpdate @2-54C34B28
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
marcwolf
Posts: 361
|
| Posted: 08/29/2005, 7:29 PM |
|
Hi DonB..
If the saved page does not redirect to a different page you can try this.
Have a lable n the page
In the BeforeShow do this
Alternatively you can have a session variable that is set in the afterupdate or the afterinsert
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 08/29/2005, 7:29 PM |
|
Hi DonB..
If the saved page does not redirect to a different page you can try this.
Have a lable n the page
In the BeforeShow do this
Alternatively you can have a session variable that is set in the afterupdate or the afterinsert
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 08/29/2005, 7:32 PM |
|
Opps.. Don't know what happened there.. I'll start again....
In the BeforeShow of the label do this.
lblUpdater.Value = session("recStatus")
session("recStatus") = ""
Then in the AfterInsert and AfterUpdate add in..
session("recStatus")="Record was Updated"
Now this will work if after inserting etc the record redisplays on the page, but if you redirect to a different page then it will not work.
By clearing the RecStatus session after showing it is clean for the next Form/record/Page
Hope it helps
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
|