Custom Control Event Problems

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
I'm working on a custom control, a wysiwyg editor (which I'm going to give out freely on this site), and like all wysiwyg editors the actual text is stored in a hidden field. I have everything coming along nicely but my child control that a set up an event for isn't registring:

In a normal form:
<input id="test" runat="server" value="asdf" type="text">
If you set up a ServerChange event for that will fire when you change the value, just like on a regular TextBox control, the event is similiar for a hidden input. The problem is that I have an instance of this control in the children controls of my custom control and an event set up:

test = new HtmlInputText();
test.ID = "test";
test.ServerChange += new EventHandler(test_ServerChange);
Controls.Add("test");

but the event never fires even when a change is made...why? How can I get an object to fire an event?
 
Last edited:
The answer is that you have to implement the INamingContainer interface is your custom control. This allows for those child controls to be unique, thus have events tied to them. It was buried deep within MSDN, but I found it!
 
Back
Top