The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
For this example we want to migrate this control to a 4.x widget that shows the same thing but if you input a user id. I know that don’t make a lot of sense (I just couldn’t think of a better example :)) but here we want to show a really simple widget migration and also emphasize the “powerful tools” that come out of the box with the migration module.
The first thing we must do is create a corresponding custom control on the 4.3 web site that we want to migrate to. The main plan is to copy all properties that we want from the 3.7 widget to the 4.3 widget so that the control works as expected. Let’s create a new class library project MyControls4x and add two .cs files IsUserAdminWidget4x.cs and IsUserAdmin4xWidgetBuilder.cs
Our corresponding 4.3 widget is going to do the same thing as the 3.7 widget but it is going to have a different interface just to make things different. The main difference is that User ID instead of a Username is expected. Remember that the corresponding widget in 4.3 can be a totally different control but in this example we’ll keep it simple.
In order to have full control over the widget migration we must plug in into the widget migrating process itself. We must create a widget builder that knows how to deal with our 3.7 widget. After that we must register the builder in the migration module configuration and that’s it.
First we must inherit from WidgetBuilderBase in order to benefit from the built-in functionality that copies all the properties of our 3.7 widget to the corresponding properties of our 4.3 widget (let’s say you don’t want to copy manually style properties like width, height, color and so on). Of course you can decide not to this, it’s up to you. Anyway the Properties property of the MigrationWidget object contains all the properties of the 3.7 widget and you can do whatever you want to do with them. Here we must override two methods
The ResolveControl methods must return our 4.3 widget type. In the Build method we can call
base.Build(widget). This one is copying all the properties from the 3.7 widget object into our new control. After that we can override some of these values if we want to or assign some properties of the 4.3 widget that are different from these in the 3.7 widget (UserId, ProviderName, ErrorMessage).
Now we must reference the MyControls4x.dll in the sitefinity web application so that out widget type can be resolved during the migration. Let’s register the builder from Administration -> Settings -> Advanced -> MigrationModule -> Widget builders. First input the 3.7 widget type and then the 4.3 widget builder type.
We are ready to go. Our widget works with users and roles, so don’t forget to select them from the migration page.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
You have the right to request deletion of your Personal Information at any time.
You can also ask us not to pass your Personal Information to third parties here: Do Not Sell My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.Learn More