This project is read-only.

Creating a new widget - can't add it to the page - why

Topics: Controls
Dec 23, 2014 at 10:32 PM
Steps taken:
  • added a directory to the widgets dir
  • created widget.xml, widget.ascx, edit.ascx
  • edited widget.ascx.cs to include the required properties (DisplayHeader, IsEditable, Name)
  • included these references:
    using System.Web.UI;
    using App_Code.Controls;
    using BlogEngine.Core.Web.Extensions
And then on the UI I can see the drop down for adding widgets and I see my new widget IN there but when I click add....nothing happens.

Here's all that's on my page

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="widget.ascx.cs" Inherits="Widgets.RSSReader.widget" %>
<asp:TextBox>hello world</asp:TextBox>

My LoadWidget() method is empty, should it have something?
    public override void LoadWidget()


Just want to get the base implementation here so I get moving forward.
Dec 24, 2014 at 6:19 PM
  • Create folder "/Custom/Widgets/Test".
  • Add web control "widget.ascx"
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="widget.ascx.cs" Inherits="BlogEngine.NET.Custom.Widgets.Test.widget" %>
<div>This is a test widget.</div>
  • Switch to code behind (widget.ascx.cs), add using directive and then inherit from WidgetBase, so it looks like this:
using App_Code.Controls;

namespace BlogEngine.NET.Custom.Widgets.Test
  public partial class widget : WidgetBase
    public override bool IsEditable
      get { return false; }

    public override string Name
      get { return "Test"; }

    public override void LoadWidget()
Now you should be able add "Test" widget to the blog.
If you need "edit" functionality, set iseditable true and inherit edit.ascx.cs from WidgetEditBase and implement interfaces.

If you want to package it for gallery so others can use it, you need to add separate project and compile it into DLL.
Dec 26, 2014 at 5:19 PM
Hi Gregoftheweb,

Also you need to make sure you are using the source version of BE and compile this on your local machine.

After you compile, "Rebuild" then you need to upload your updated BlogEngine.Net .DLL to your server for it to work since it is now all compiled.
Dec 29, 2014 at 5:04 PM
Edited Dec 29, 2014 at 9:48 PM
Updated this thread - found it. Like I always say - its the developers fault.

My inherits statement is incorrect in the ASCX.

Here is my code:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="widget.ascx.cs" Inherits="BlogEngine.NET.Custom.Widgets.Test.widget" %>
<div>hello world</div>
Notice something?

Says blah blah blah TEST.widget should be blah blah blah RSSReader.widget. Changed it and works.
Apr 2, 2016 at 5:05 AM
When you say "compile this" what do you mean? The entire source files? The DLL files? If so, what DLL files? Or just the widget or control that you modified? How do I add in the source version of the files once I've started editing the web version? Won't that copy over my edited files? I'm confused.
Apr 16, 2016 at 10:23 PM
Hi Khambley,

Since BE is now an "Web Application" any time you edit any .cs files C# you have to recompile the entire solution.

To be able to edit .cs files you have to start with the source version first and not web only.

If you are editing .cs codebehind files don't think you have to recompile.

But, editing the widgets and core you do.

Hope that helps.