This project is read-only.

Usercontrols in Pages?

Topics: Controls
Mar 26, 2009 at 2:26 PM
Is there a way to incorporate usercontrols in a blogengine page?  If not this would be a nice feature
Mar 27, 2009 at 6:27 AM
Edited Mar 27, 2009 at 6:30 AM
You can use UserControls in BE.  Some of the pages in BE already use UserControls.  An example is default.aspx.  In the top of that file, you'll see the declaration:

<%@ Register Src="User controls/PostList.ascx" TagName="PostList" TagPrefix="uc1" %>

And the UserControl is later used in that page ...

<uc1:PostList ID="PostList1" runat="server" />

EDIT:  I saw you said "blogengine page".  If you're referring to Pages that can be created in BlogEngine, then I guess it's not currently possible to add usercontrols into a Page.  You still have the option of creating an ASP.NET Content page that inherits from BlogBasePage like as is done in default.aspx, contact.aspx, etc.  UserControls can be added into Content pages.
Mar 30, 2009 at 7:02 PM
It turns out UserControls can be used in BE Posts and Pages :)  I saw a glimpse of this before, but didn't spend time familiarizing myself with it at the time.  You can use syntax like below in Pages and Posts.  BE will replace this custom markup with the usercontrol you ask for.  This particular example is using the SinglePost UserControl.

[usercontrol: ~/User controls/SinglePost.ascx ShowDate=false;ShowAuthor=false;postID=07699adc-e8c0-42a4-814c-aea67705734e]
Mar 30, 2009 at 7:14 PM

Thanks for your help, that is exactly what I was looking for.  Works perfectly.