This is a well-known issue with WebParts. It was fixed in the "ASP.NET Futures CTP (July 2007 release)", but for some reason the fix was never added to the framework. The CTP is no longer available, and you wouldn't want to use it in a .NET 4 project anyway.

The problem was reported to Microsoft[^], but they closed it as "won't fix" because it was too complicated to implement.