Skip to main content

Finding whether its Design Mode or Runtime Mode in VB.NET

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.

Comments

Featured

You are in a cold conference room, Do you want to use your mac as a heater?

Imagine that you are in cold conference room and you kind of feeling the cold on your head. What do you do when you are in a serious meeting and just can't get out?

If you have a MacBook, you might have a solution.

Use your terminal to run either of these commands to keep your CPU at above 80% or if you want you can run them both.

$ openssl speed

and/or 

$ yes > /dev/null

The first command just outputs the ssl cryptography stats and it keeps your cpu busy. The second command just prints the character "y" into IO.

So try it out and let me know how it works! :D


Talk to me on Twitter, Facebook, LinkedIn or Website
You will receive wonderful short stories written by him and inspirational articles once every month.