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

Rails Engine - How To Keep Your Engine Migrations Abstracted From Your Host Rails App

Have you ever worked on building a Rails Engine and wanted to keep the models, the migrations and everything inside the engine rather than using a generator to copy paste them into your host Rails App? That's a problem everybody faces one time or the other when building Rails Engines to abstract out your huge Rails App. I have found one such solutions that can be helpful for you to keep them separate. Here is a solution for it.
Problem Statement: Instead of using

    rails g my_engine:install
to copy paste the migrations from engine to your rails app, you want to just keep the migrations inside the Rails Engine and do not bother about it.
Solution:  Add the following lines to your engine, so that your engine's migration files are added to the rails app as well.

Now you can do the following from your rails app to run your migrations as you always do:

rake db:migrate
Hope it helps you! If it does help you, give me a shoutout below!

Talk to me on Twitter, Facebook, LinkedIn or Web…

Popular Posts

You will receive wonderful short stories written by him and inspirational articles once every month.