Sometimes, while creating controls, either by Inherited Controls or UserControls, we will be required to skip a piece of code depending upon the design time or runtime mode. This can be done easily by the following code inside a control.
If Me.Site IsNot Nothing AndAlso Me.Site.DesignMode = True Then 'Designtime code here Else 'Runtime code here End If
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.
![[VB.NET] Finding whether its Design Mode or Runtime Mode for Forms](https://www.jeygeethan.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTA4LCJwdXIiOiJibG9iX2lkIn19--02a207fb21e62c2d52791c4a53fc2ce9e251679f/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGVnIiwicmVzaXplX3RvX2ZpdCI6WzgwMCw4MDBdfSwicHVyIjoidmFyaWF0aW9uIn19--cfb9b5ee4affce3d9631a47d315e7e009392c6a2/DesignTime.jpeg)

![[.NET Error] Update requires a valid UpdateCommand when passed DataRow collection with modified rows](https://www.jeygeethan.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTA2LCJwdXIiOiJibG9iX2lkIn19--e91253d80eb7ffc54f54bf32fb1b812a381fd52f/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemVfdG9fZml0IjpbODAwLDgwMF19LCJwdXIiOiJ2YXJpYXRpb24ifX0=--e6e6a0f38c858cc47eaf7fc395a39df3afd3bb47/hPTMJ.png)
