Hey guys, welcome back. Today we’re going to talk about MVC and why is important to the future of Sitefinity
An ASP.NET MVC Widget Example
In my last few videos, I’ve been talking about MVC and how it works with asp.net and this video, we’re going to look at how MVC applies to Sitefinity going forward. Sitefinity uses MVC and it really makes things a lot easier. If you look at this example here, I’m creating an entire widget using an MVC construct, so to create an NBC widget you literally use a controller, which I kind of demo in the last example.
So we have this example widget controller that I’ve created here that also inherits from the controller. But again, very simple to what we have seen for just an MVC concept. Here we have an action results index controller and that gets data and we return that to have you and that model data is using a model class of plain old class. Now we return that data to a view.
Now this set of files here was generated by a Sitefinity CLI and you can see what that looks like. Over here. On this MVC folder, we have a controller models, scripts, views, and we also have a shared folder which is very similar to what we had in a normal asp.net MVC website. So we look here, we have an index that’s the html file and that creates our view. There’s a few other files in here. This one called designer view. Simple creates our designer view or our edit view behind the widget and gives you a very simple way of modifying a widget properties.
An ASP.NET Web Forms Widget Example
Now let’s compare that to a Web Forms widget. A Web Forms widget looks a little bit different.
First you have this class rotator, which this is a simple news rotator that displays news articles in a rotating manner. Instead of implementing a controller, you’re implementing a simple view here and from there you’ll then implement the various properties that are needed for a simple view widget.
For example, here’s the default layout. And down here there are several other provided overrides that are displayed here, such as the provider name. If we scroll down a little bit further, we can see that we have overwritten this property called layout template name, which this allows us to see which template to load based on one of the provided templates here in the views folder. So there’s a lot of overrides and just different things like that that you have to do in a Web Forms template that an MVC template tends to just take care of for your next site. Sitefinity has now reclaimed that MVC is the preferred way of coding. This article that came out in May 31st of 2018 confirmed that going forward and Sitefinity 11 and beyond, everything in Sitefinity will be developed using an MVC web forms has kind of taken a back seat and going forward, even with the newer technologies such as asp.net core web forms, really won’t have a option there.
And so MVC really is the new route for all of this. And so I think that’s really gonna confirm it. So all new innovation going forward in Sitefinity will be done on MVC. One way to show this very clearly is in the forms module, so I’ve created two forms here, and Web Form and a web form and I’m going to show you the differences between these two. In this MVC form, we have the ability to add several more different tools from the toolbox here and on top of that there’s more options. For example, if I drag a text on here and I edit that text box field, you can see that we can set different values here. We can also define a template and we can also determine the type. For example, if we want it to be a telephone number field, we could do that in our web form control and you can see the layout a little bit different.
If I click on limitations, I don’t get a lot of choices here that I got in the MVC version of this same control. Another interesting thing about web form controls is that they don’t have the options to any kind of rules in their forms where the MVC forms allow you to do that. Now in version 12 of Sitefinity, I guess this pretty much demonstrates that going forward Sitefinity is now going to pursue MVC options versus web form options.
Thanks for reading and stay craig on coded.