ross dickinson: web and desktop software developer

Added Widget Theming Support to BlogEngine.Net

by Ross on October 12, 2010 at 9:33 PM under ASP.Net | BlogEngine.NET

I just added a new fork on BlogEngine's codeplex site that adds widgets to the available areas themes have access to. Hopefully it'll get added to the main release!

Originally, BlogEngine was adding extra markup inside WidgetBase's Render method, which made it impossible to change unless you had access to the source code. That's usually not the case when dealing with theme creation. Later on, another change was made to WidgetBase that allowed it to support Photoshop image slices that only needed to be altered with CSS. While this is probably cool for a few people, this mostly just added a lot of excess markup to the final page. I'm a man who likes his markup slim, so this bugged me.

I thought it over a bit and realized that making a similar setup to the PostView/CommentView classes would allow a lot more flexibility and customizability for users. I created a class called WidgetContainer, a simple UserControl derived class thats sole purpose is to house a WidgetBase derived control. This class is easily themed by creating a WidgetContainer.ascx user control and adding it to a theme's directory.

The major benefit of this is that users can now have full control over their widget's markup without needing access to WidgetBase's source code.

To create a WidgetContainer theme, the only thing required is that it contains a control with the ID "phWidgetBody". That control only needs to derive from the Control class and allow children to be added to it. The WidgetContainer looks for this control at load time and adds its Widget instance to it.

Add comment

  • Comment
  • Preview

About the author

rossisdead is a 26 year old web and desktop software developer from New Jersey. He has two cats and likes long walks on the beach.

On Stackoverflow

On Stackoverflow Careers

On Codeplex

On Github