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.
It is often needed to extend some of the capabilities of Sitefinity built in widgets. Since the widgets implementation is in Sitefinity assemblies the code files are not directly accessible. To override the methods for the widgets it is needed to inherit from the built in widget and override some of the methods. I will describe two approaches for doing so. One involves inheriting from the widget and creating new control with the modified logic. Another approach is to replace the built in widget with the modified one. The two approaches are interconnected.
First approach:
1. Create a new class in the Sitefinity solution. Then must find out how to inherit one widget. For this example I will be inheriting Sitefinity login control.
2. To find the needed path that should be inherited (Telerik.Sitefinity.Web.UI.PublicControls.LoginControl) go to Administration->Settings->Advanced->Toolboxes->PageControls->Sections->Login->Tools->Login and find textbox: Control CLR Type or Virtual Path. In it you can take the path Telerik.Sitefinity.Web.UI.PublicControls.LoginControl as well as other properties that will not be needed fro this example.
3. In the .class file created in step 1 inherit from Login Control. The class should look like this.
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
namespace
SitefinityWebApp.Custom
{
public
class
Class1 : Telerik.Sitefinity.Web.UI.PublicControls.LoginControl
{
}
}
type override keyword to access a list of all methods that can be overridden. Make sure you are calling the base method when overriding to be sure the built in implementation for this method will also be included (base
.LoginForm_Authenticate(sender, e);
).
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
namespace
SitefinityWebApp.Custom
{
public
class
Class1 : Telerik.Sitefinity.Web.UI.PublicControls.LoginControl
{
protected
override
void
LoginForm_Authenticate(
object
sender, System.Web.UI.WebControls.AuthenticateEventArgs e)
{
base
.LoginForm_Authenticate(sender, e);
}
}
}
5. Now register new widget that will be the modified login control.
For more information, see Registering a new widget in Sitefinity.
Go to Administration->Settings->Advanced->Toolboxes->Toolboxes->PageControls->Sections->Login->Tools and click create new button in the main content area. Register the control with
Control CLR Type or Virtual Path: SitefinityWebApp.CustomizedLoginControl
Name: CustomizedLoginControl
The customized control is now available in page edit screen under the Login section and the control is called CustomizedLoginControl.
Note some of the built in widgets that have separate views like news, blogs, events have two views.
MasterListView this is the view that displays a list of all news, blogs, events items and sorts them.
DetailsView displays full contents of a single content item blog post, news item, event item.
Both views are using separate code file so the first approach with registering only one code file as a single control will not be of much use in this case. Refer to the second approach where you will be able to insert logic into a separate view (MasterListView or DetailsView).
Administration->Settings->Advanced->ContentView->Controls-> here a big node is expanded that list most of the backend controls. Go to NewsFrontend->Views and here you will see NewsFrontendList and NewsFrontendDetails. This naming is the same for all widgets that have two views (MasterList and Details).
To use different logic for NewsFrontendDetails click the menu item and find the textbox ViewType with content: Telerik.Sitefinity.Modules.News.Web.UI.DetailsSimpleView, this is the path from where the newsDetails code is taken and the path that we need to inherit.
Inherit Telerik.Sitefinity.Modules.News.Web.UI.DetailsSimpleView in the class file created at step one and you will be able to overwrite methods from DetailsView.
To use the new DetailsView register it in the same box ViewType.SitefintiyWebApp.CustomDetailsViewClass. (the full path to the class file, namespace.class of the newly created class file.
namespace
SitefinityWebApp.FolderWithTemplates
{
public
class
CustomNewsDetailsView : Telerik.Sitefinity.Modules.News.Web.UI.DetailsSimpleView
{
It is best you first test modifing the built in views on a test project first before making such modifications to the project.
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.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share 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.