events

JQuery: how do I see which events are defined on an element?

I use $(window).bind( ... ) to set up event handlers, but for some reason I keep losing event handlers (i think). Is there any way when debugging (firebug) to see which custom events have been added to a given element? Yours Andreas ...

Javascript: Event does not fire unless element appended to document.body

Hi All, I dynamically create an element (div) in javascript, on which i register an event listener: var tooltip = document.createElement('div'); tooltip.onclick = function() { alert('hello'); } Now, if I attach this element to the document body: document.body.appendChild(tooltip); all is well and the event is captured. However (fo...

Clicking checkbox causes onCheckedChanged to fire twice

I have a GridView with a TemplateField with a checkbox. My goal is to capture the onclick event using autopostback and setting a database flag. My only problem is that the event fire's twice. The first time The Checkbox (In the sender parameter) holds the clicked value so I set it based on the click. The second time the sender parameter ...

Event handling in Dynamic asp.net user Control

Hi all, I Have a page, where I want to dynamically add asp.net user controls. The scenario is that we want that on specific event of a control, It disposes itself and loads another control in the page. I am not able to have solution how to do this? any one have decent Idea, Please help.. Thanks Singh Ajay ...

How to stop event propagation with inline onclick attribute?

Consider the following: <div onclick="alert('you clicked the header')" class="header"> <span onclick="alert('you clicked inside the header');">something inside the header</span> </div> How can I make it so that when the user clicks the span, it does not fire the div's onclick event? ...

How does "Custom Event" work in VB.Net?

In C# if I want to create a "Custom Event" you do something like this: private EventHandler _MyEvent; Public Event EventHandler MyEvent { add{ _MyEvent += value; } remove{ _MyEvent -= Value; } } protected void RaiseMyEvent() { if(_MyEvent != nul) _MyEvent(this, EventArgs.Empty); } In VB this is not so straightforward n...

How to retrieve sender in click handler from toolbartray or other control in wpf?

XAML: <ToolBarTray Name="tlbTray" ButtonBase.Click="tlbTray_Click"> <ToolBar Name="tlbFile"> <Button Name="btnOpen"><Image Source="images\folder.png" Stretch="None" /></Button> <Button Name="btnSave"><Image Source="images\disk.png" Stretch="None" /></Button> </ToolBar> </ToolBarTray> Code: private void tlbTray_Click(object ...

onbeforeunload in Opera

Hi, I'm using the code that netadictos posted to the question here. All I want to do is to display a warning when a user is navigating away from or closing a window/tab. The code that netadictos posted seems to work fine in IE7, FF 3.0.5, Safari 3.2.1, and Chrome but it doesn't work in Opera v9.63. Does anyone know of way of doing th...

How to Issue Targeted C# Events to Specific Event Handlers?

Suppose I have a Customer object that can enter multiple Stores and shop simultaneously. When a customer enters a Store, the Store will begin to handle the Customer's triggered events. To purchase an item, the Customer currently triggers a PurchaseItem event with the particular item specified in the EventArgs. Currently, since the Custo...

Lazy binding functions to multiple events with jQuery

Here's the scenario: I have a set of buttons that I want to bind to corresponding functions when clicked. The ids of these buttons are the same as the names of their corresponding functions. I could do this: $("#kick").click(kick); $("#push").click(push); $("#shove").click(shove); But I'm lazy and would like to do this more lazily (as...

WinForms Load vs. Shown events

Hopefully I'm just missing something obvious, but I'm trying to get my head around the differences between the Load and the Shown events in WinForms. Traditionally I've only used Load (or actually OnLoad, since I think it's cleaner to override a method than to rely on the designer to hook up an event on yourself), since that is availabl...

incrementing array value with each button press?

Hi, I am building a calculator in C#. I am not sure what the best way is to have it increment a number in an array every time the button is pressed. Here is one of my current button event handler methods: //Assign button '2' to 2 with array address of 1 private void num2_Click(object sender, EventArgs e) { numbers[1...

VB to C# Translate Event Handler that Implements Interface Event

I was looking at code in WPF which is in VB. I am trying to convert it to C#. Eventhough I used VB .Net to C# converter I cannot figure out the correct syntax for the following code in C#. Any ideas how to write this in C#? VB Code: Public Event PropertyChanged As PropertyChangedEventHandler Implements System.ComponentModel.INotifyPro...

Preventing same Event handler assignment multiple times

If I am assigning an event handler at runtime and it is in a spot that can be called multiple times, what is the recommended practice to prevent multiple assignments of the same handler to the same event. object.Event += MyFunction Adding this in a spot that will be called more than once will execute the handler 'n' times (of course). ...

Custom events in jquery?

I'm looking for some input on how to implement custom eventhandling in jquery the best way. I know how to hook up events from the dom elements like 'click' etc, but I'm building a tiny javascript library/plugin to handle some preview functionality. I've got a script running to update some text in a dom element from a set of rules and da...

How can I get the length of a JTextField's contents as the user types?

JTextField has a keyTyped event but it seems that at the time it fires the contents of the cell have not yet changed. Because of that .length() is always wrong if read here. There must be a simple way of getting the length as it appears to the user after a key stroke? ...

Raising javascript event from an ASP.NET user control and handling in ASP.NET page

In an ASP.NET page I have a user control and I want to perform some action within it using javascript. When that action is complete I want to raise an event (again in javascript) to be picked up by the containing ASP.NET page (again in javascript). The reason I want to do this is because I have more than one user control on the page and...

How do I implement QHoverEvent in QT?

I'm just learning QT with C++. I have successfully implemented signals and slots to trap standard events like ButtonPushed(), etc. However, I want to have a function called when I mouse over and mouse out of a QLabel. It looks like QHoverEvent will do what I need, but I can't seem to find any tutorials or examples on how to implement thi...

Visual Studio web user control events only show up in design mode?

Calling all Visual Studio gurus — when I'm working on a .ascx or .aspx file in a c# web project, the events do not show up in the properties panel unless I switch into the design view from the code view. Is this an intentional functionality of Visual Studio? Both VS2005 and VS2008 seem to work this way. And is there any way to get the e...

How Do I Pass A Method Reference to A Different Method in C#

I would like to pass a reference of a method into another method and store it as a variable. Later, I would like to use this reference to define an event handler. When making an event handler, a method reference is passed like: myButton.Click += new RoutedEventHandler(myButton_Click); And if you look at the constructor for "RoutedEv...