events

Is redirection of events a good practice in C#? If true, who should be the 'sender'?

I am now refactoring a code written by someone else and I have found a construct that I have mixed feelings about. There is a ListView-like control and each of its items can raise 'DialogOpened' event. However, it may be cumbersome to register external event handlers to each of the items (and the items may be added or removed dynamically...

Is it a good practice to implement Template Method Patter via C# events?

I am now trying to understand some code and I have found a pattern, which seem a bit strange to me. There is a user's control class with 'EditorOpen' event. At first, I thought this name is incorrect, because it does not end with '-ing' or '-ed', as MSDN suggests. However, later I have found out, that this event does not INFORM about som...

WPF Rectangle does not have a Click event

It seems that the WPF Rectangle shape does not have the Click event defined. What am I supposed to use instead? It does have MouseUp, but it's not quite the same behavior. ...

Design question - using an event, attribute, or not? (mvc)

I'd like to know what you think of the following design options. I have an 'AgendaController' (.NET MVC project) which handles user actions like viewing their agenda, making appointments, etcetera. When a user makes an appointment, the appointment is saved in a database. Then, there is a 'secondary' task that has to be done, in this cas...

How to implement AJAX data collection properly?

I'm currently implementing a small application driven by a YUI DataTable. For this DataTable I need two configuration arrays, which I both get from server with an XHR. However, my current implementation makes me wonder how these things are done properly. What I have now is two asynchronous AJAX requests which both set their respective d...

postback not raised problem

Hi, I have next situation: I load dynamic controls during on init, and I do correct initialization. I add dynamic control before postback I don't add anything later in load control is loaded and diplayed correctly I press postback and nothing happens Why I really don't know.. I tried everything. So control IS properly initialised. __...

.Net Event Logging

I am trying to get the new System.Diagnostics.Eventing event logging working in a simple .Net app before integrating it into my application. Working off of this page, I created a manifest, built a simple app that fires an event and registered the provider to see it in the event viewer. I don't get any errors in event viewer or my sampl...

Design Question – Polymorphic Event Handling

Design Question – Polymorphic Event Handling I’m currently trying to reduce the number of Event Handles in my current project. We have multiple systems that send data over USB. I currently have a routine to read in the messages and parse the initial header details to determine which system the message came from. The headers are a lit...

[jQuery] Modify the show/hide function to only scale width, not height?

As the title implies, I'm using jQuery's show and hide functions to hide and show elements. However, I don't want to scale in the height of the element, just the width. I was thinking about using the animate function but I wasn't sure if this was the best way to go about it. Also, I'd prefer not to have to set the height in the javascr...

Prevent events from firing multiple times from single action

How can I prevent the firing of multiple events of the same kind triggered by a single action? For example, I have a ListView containing some items. When I select or deselect all items, the SelectedIndexChanged event is fired once for each item. Rather, I would like to receive a single event indication the user's action (selection/desel...

Handle MasterPage event on ContentPage

I have a button on my MasterPage and I want the ContentPage to handle the Click event of the button. Here's what I have so far: //Event in MasterPage public event EventHandler Search_Submit; //ButtonClick event in MasterPage protected void SearchButton_Click(object sender, EventArgs e) { if (Search_Submit != null) ...

Javascript Event Synchronization

I'm building a concert calendar that's very heavy on javascript (using jQuery). I'm having trouble synchronizing various events throughout the app, and I'm looking for suggestions for how to do this. An example of a simple use case: User clicks a month Calendar skips to that month An example of a more complex use case: User selec...

Do I need to remove event subscriptions from objects before they are orphaned?

If my software has two object instances, one of which is subscribed to the events of the other. Do I need to unsubscribe them from one another before they are orphaned for them to be cleaned up by the garbage collector? Or is there any other reason why I should clear the event relationships? What if the subscribed to object is orphaned b...

Is it possible to handle up/down key in HTML input field?

I am building a autocomplete feature for input text field. Currently I could use mouse click to choose the selection, I'd like to add keyboard control to allow autocomplete control. I monitored the keycode in onkeyup event, it appears for up/down key, the key codes are both 0. I am wondering whether there is any better way to do so. T...

Receive input from mute/play/stop/etc. on front of Dell Inspiron laptop

I have a Dell Inspiron E1505 and as you can see in this image it has some buttons on the front for mute, play/pause, stop, volume control, etc. The mute and volume buttons actually affect the volume settings for the computer itself, but the others can also be used to control some other applications, such as Windows Media Player and even ...

Prevent default behavior in text input while pressing arrow up

I’m working with basic HTML <input type="text"/> text field with a numeric value. I’m adding JavaScript event keyup to see when user presses arrow up key (e.which == 38) – then I increment the numeric value. The code works well, but there’s one thing that bugs me. Both Safari/Mac and Firefox/Mac move cursor at the very beginning when I...

How to expose and raise custom events for a vb.net winforms user control

Hello, Please read THIS post. I have the same problem as described in this post but I am trying to do in in VB.net rather than c#. I am pretty sure to do this I have to use a custom event. (I used a code conversion site to get to learn about custom events.) So in the IDE when I type the following: Public Custom Event AddRemoveAtt...

Accessing an object's property from an event listener call in Javascript

Below I am creating an object in Javascript. Within the constructor I am setting up an event listener. The problem is that when the event gets fired, this.prop cannot be found, and undefined prints out. How do I solve this? var someObj = function someObj(){ this.prop = 33; this.mouseMoving = function() { console.log(this...

What JEditorPane event should I create a listener for?

Suppose I have a JEditorPane in a JPanel. I want to be able to execute a callback each time the user enters/pastes text in the JEditorPane component. What type of listener should I create? ...

VBA: Using WithEvents on UserForms

I have a Word userform with 60+ controls of varying types. I would like to evaluate the form every time a control_change event is triggered and change the enabled state of the form's submit button. However, I really don't want to write and maintain 60 on change event handlers. Could anyone help me out? Cheers ...