Dec 16, 2006 08:56 PM|davidebb|LINK
You guys pretty much figured this one out. Ideally, this would just work directly (i.e. you could use Label1 directly in the handler), but the current implementation doesn't allow it. This is because in order to make this work, the IronPython logic needs
to insert itself on the stack to make the right context available. For Page_* methods, and when you do the hook up on the tag, the IronPython logic is in the picture and can do the right thing. But when you do the event hookup yourself (via +=), this goes
straight to ASP.NET, and IronPython doesn't get to insert the right context when the event is fired.
Hopefully we'll find a way to fix this. For now, your sender.Page workaround is fine. However, be aware that
it will not work correctly if you move this logic to a User Control (or master page), because sender.Page will evaluate to the Page, and not the User Control!
On the other hand, doing the hookup on the tag will always work correctly, so that would be my recommendation.
Hope this helps.