Community blog feed

ASP.NET server controls not getting events from child controls?

Website
Blog
Simon Soanes
Posted
04 Jul 2009 at 23:12

Summary

My ASP.NET server/composite controls were not getting events from child controls, but only on the real pages, they worked fine on test ones. It turned out that I had a master page enabled but didn't have an ID set for it, so it was auto generating it. Just add this to your master pages code file:- protected override void OnInit(EventArgs e) { base.OnInit(e); this.ID = "SomeName"; } And child controls will start working as expected.

Post extract

My ASP.NET server/composite controls were not getting events from child controls, but only on the real pages, they worked fine on test ones.  It turned out that I had a master page enabled but didn't have an ID set for it, so it was auto generating it.

Just add this to your master pages code file:-

protected override void OnInit(EventArgs e) 
{ 
	base.OnInit(e); 
	this.ID = "SomeName"; 
}

And child controls will start working as expected.  I don't often do web development so this stumped me for quite a while...

We'd love to hear what you think! Submit ideas or give us feedback