Finding whether its Design Mode or Runtime Mode in VB.NET
If Me.Site IsNot Nothing AndAlso Me.Site.DesignMode = True Then
'Designtime code here
'Runtime code here
Using this code in a control, we can find the mode and avoid certain errors when in Design Mode. This is mostly used in overridden event methods in Inherited Controls.