473,624 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

An "All the time" event?

Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's
kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or
in another filed, I want that Total filed to be Updated...

/Lars
Nov 20 '05 #1
4 1272
Nope.

couple reasons.

1) Thats a lot of friggin events

2) Each event has its own signature. While many are the same, there are
many that are different. No "universal" event handler.

3) Not that many events fire on an ASP.NET page at once... Usually, 1...

4) If you want to catch something each time it happens in ASP.NET the
Page.Load event is always the first one fired, and you can validate whether
its a postback or not.

5) Look into storing values in the viewstate... or the session object.

hope it helps.

-CJ

"Lars Netzel" <[no_spam_please]la*********@qlo gic.se> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #2
You could try hooking up all your controls Leave Events or Validating Events
(if you aren't using them for something else) to one event handler and call
your update form there.
"Lars Netzel" <[no_spam_please]la*********@qlo gic.se> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #3
Lars,
In addition to CJ's comments.

Have you separated your UI from your Domain/Data objects? This should be
easy! In your domain objects as properties change, the Total property would
change. If you don't have Domain (business) objects per se and are binding
directly to Data objects (such as a DataSet/DataTable) you can use the
events on the DataTable itself to update to total fields. Such as
DataTable.Colum nChanged, DataTable.RowCh anged and DataTable.RowDe leted.

An alternative:
Remember that an Event can be handled by more then one handler, and that a
single handler can handle events for more then one object.

The "problem" as CJ suggested, is that the signature of the event handler
needs to match the signature of the event. You may need two extra
handlers...

You could have an extra Changed event handler that would update the total
field, for each of the UI controls, they would have their own Changed event
handler, plus this extra Changed handler would handle the changed event.

Private Sub Text1_Changed(. ..) Handles Text1.Changed

Private Sub Text2_Changed(. ..) Handles Text2.Changed

Private Sub Text3_Changed(. ..) Handles Text3.Changed

Private Sub AnyText_Changed (...) Handles Text1.Changed, Text2.Change,
Text3.Changed
' calculate total amount
End Sub

You can use VS.NET to set the first three Changed event handlers, however
you will need to type in the third event handler.

Hope this helps
Jay

"Lars Netzel" <[no_spam_please]la*********@qlo gic.se> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #4
Lars,
I should add, rather then using the Handles syntax to add the event handlers
on the Changed event handler you could use a For Each loop over the Controls
collection and use AddHandler to add the extra event handler.

Private Sub Form1_Load(...) Handles MyBase.Load
For Each ctl As Control In Controls
If TypeOf ctl Is TextBox Then
AddHandler DirectCast(ctl, TextBox).Change d, AddressOf
AnyText_Changed
ElseIf TypeOf ...
...
End IF
Next
End Sub

Note: if you have panels & other controls that may be nested, you may need
to make the above recursive on ctl.Controls!

Hope this helps
Jay

"Lars Netzel" <[no_spam_please]la*********@qlo gic.se> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...
Is there any way to add some code that will happen in every single Event
that i raised in a form?

I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might
affect it

Is there are was to keep that Filed Total (a value) updated at all time
without having to think about it in every single event on the page?

Nomatter what happens and what fileds are updated on the page.. in a grid or in another filed, I want that Total filed to be Updated...

/Lars

Nov 20 '05 #5

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

Similar topics

10
12831
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following SQL commands will return the same result but one of my friends don't think so. He said "QUERY 1" will return 1 unsorted record (ROWNUM < 2 ) first then sort the result (ORDER BY COL1 ASC,
0
1502
by: Sham Yemul | last post by:
Hello, We developed an application that has many data entry forms and data controls in Vb.net and Sql Server2000 as backend. For this application we created connection object on load event of every form. The application runs on Server machine with no errors. We got some errors when the application/.exe run on client node, There is no error till log-in happens, the log-in form uses connection object. After that , when we click to open...
2
2495
by: Dale Ring | last post by:
Access 2000 I am trying to add "ALL" to a combo that is used to filter a query. When "ALL" is selected no records show instead of ALL records showing. I have setup a "dummy" table (tblDum) with 1 field (txtDummy, Integer)with 1 record that has a "0" entered. The field that is being filtered is an Integer type.
9
6008
by: rnn98 | last post by:
hi, my multithread application, running under solaris box, is crashing eventually. I tried to spot and substitute functions not "thread safe", but I guess my search wasn't good enough. I have put localtime_r and asctime_r where I was using localtime and asctime. But I didn't find any correspondent _r function to "time".Also, I found that "readdir" is not thread safe. But what about "scandir"? Thanks for any help
175
8768
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
1
1384
by: S.Guhananth | last post by:
I need to capture a country from dropdown list and use that in sql query. How to do this protected DataSet GetCountry() { I have the code for this block
17
3908
by: teddysnips | last post by:
One of my clients has asked me to make a change to one of their Access applications. The application is a Front End/Back End standard app. I didn't develop it, but looking at it tells me that it was done entirely using the Wizards. There is no log-in procedure. They want to amend it so that only one person can be logged in at any one time. So, if Joe Bloggs tries to open the application, and Fred Jones has already connected, Joe...
19
10740
by: Daniel Pitts | last post by:
I have std::vector<Base *bases; I'd like to do something like: std::for_each(bases.begin(), bases.end(), operator delete); Is it possible without writing an adapter? Is there a better way? Is there an existing adapter? Thanks, Daniel.
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8471
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.