This project is read-only.

<blog:LinkList ... /> ?

Topics: Controls
Jan 14, 2009 at 10:42 PM

why isn't there something like <blog:LinkList ... />? How could I "simulate" this control?
I'd like to have some controls on my frontpage an show others if I'm not on the frontpage (just started the discussion about getting to know if I'm on the frontpage).

Do you have any idea?


Jan 20, 2009 at 4:19 AM
You can manually add the LinkList user control, but you have to do a little bit of work to get it going.  One way to add it is to set it up in design time.  You would register the UserControl at the top of an ASPX page:

<%@ Register Src="~/widgets/LinkList/widget.ascx" TagPrefix="widgets" TagName="LinkList" %>

Then somewhere in your page:

<widgets:LinkList ID="LinkList1" runat="server" />

Then you need to set some properties.  You can either set them above after runat="server" in the tag above, or you can set them in code.  The LoadWidget() method needs to be called in code.

LinkList1.WidgetID = new Guid("bf17fc53-ef08-4df3-ab58-e18671905ecd");
LinkList1.Title = "LinkList";
LinkList1.ShowTitle = true;

The WidgetID I had to manually lookup.  It'll be a different Guid in your case.  It is the Guid in the be_WIDGET_ZONE.xml file (under App_Data\datastore\widgets), and there's also a file named bf17fc53-ef08-4df3-ab58-e18671905ecd.xml in App_Data\datastore\widgets.  A new line in the be_WIDGET_ZONE.xml file and a new file gets created for each LinkList you add to the widget zone.

The other way to add the LinkList is similar, where you do it all from code.

string LinkListUserControlFile = "~/widgets/LinkList/widget.ascx";
if (System.IO.File.Exists(Server.MapPath(LinkListUserControlFile)))
    WidgetBase linklist = (WidgetBase)LoadControl(LinkListUserControlFile);
    linklist.ID = "MyLinkList";
    linklist.WidgetID = new Guid("bf17fc53-ef08-4df3-ab58-e18671905ecd");
    linklist.Title = "Link List";
    linklist.ShowTitle = true;

In both cases, the LinkList you add might look a little different than the one in the widget zone because of styles in the CSS file being applied only to widgets in the widget zone.  Like the one below ... it removes the bullet points in front of each link (this is in the Standard theme's CSS file).  If you manually add a LinkList to your page outside of the widget zone, it'll by styled differently unless you modify the CSS file.

#widgetzone .widget ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    text-transform: capitalize;

Depending on how much the LinkList is worth to you, it may not be the easiest or best option to spend the time getting all this working ...