Tagged with events
Lists are a killer app for generics in .NET 2.0 but one of my favourite uses that gets less attention is declaring event handlers without having to create a custom delegeate. Imagine a situation where you want to pass a piece of custom information to the event handler so it can decide whether to cancel [...]
Published in .NET on Saturday, April 26th, 2008
One recurring problem I’ve had when using a function from a custom javascript object as an event handler is that when the event handler is called the “this” property of the function no longer references the object it originally belonged to. To show you what I mean, take a look at this simple javascript object. [...]
Published in Javascript on Saturday, April 26th, 2008
I wanted to document a bit of an edge case browser incompatibility that I found: that event handlers aren’t always run in the same order in IE as they do in other browsers. It’s a bit of a strange case where we were doing something not entirely sensible. :) There was an input box which [...]
Published in Browser quirks on Wednesday, January 16th, 2008
Step 1: Create a WebControl that implements the IPostBackEventHandler interface. In my example I’ve created a CustomButton control that is a HTML <span> element that acts like a real button by trigging a postback and firing a Click event. public class CustomButton : WebControl, IPostBackEventHandler { public CustomButton() { } public void RaisePostBackEvent(string eventArgument) { [...]
Published in Server controls on Monday, October 24th, 2005
Came across an interesting problem yesterday trying to handle the SelectedIndexChanged event for a DropDownList that was inside a Repeater. I found a wonderful article on Databinding that gave me most the information I needed, but their method of handling events just didn’t work for me. My first problem was that I originally did the [...]
Published in ASP.NET, Javascript on Tuesday, January 25th, 2005
One of the problems I had when I first started creating Javascript widget objects is that I always needed to create the object in two stages. First I’d actually create an object with the correct parameters, then I’d register a piece of script that actually did all of the initialisation code that accessed the DOM [...]
Published in Javascript on Tuesday, November 23rd, 2004
First you need to declare an event in the class that’s going to raise the event. This is just like declaring a normal variable: public event EventHandler MyEvent; Then you need a method that’s going to be called to raise the event. This goes into the same class that you just declared the event in. [...]
Published in .NET on Wednesday, November 3rd, 2004