an ASP.NET Open Source CMS & eCommerce platform
Search:
Skip Navigation LinksHome > DotShoppingCart Blog > Customization > Add a custom ASP.NET UserControl into the DotSh...
Add a custom ASP.NET UserControl into the DotShoppingCart page

DotShoppingCart CMS page is comprised by the server blocks, which are the pre-built server side controls. The out of box software comes with a handful of common blocks. The article is going to talk about creating your own server block.

Notice: read this blog entry for DotShoppingCart V2.5+.

1) Create the Standard ASP.NET stardard User Control and derive it from DotShoppingCart.OpenSource.Core.BlockUserControl

In the Page_Load method add the following code.

 public partial class YourCustomControls : BlockUserControl {
    protected void Page_Load(object sender, EventArgs e) {
        EnableViewState = WebUtils.IsPageEditorEnable();
        editor.BlockUserControl = this;
        if (ShowEditor) {
            pnlBlockContent.CssClass = "BlockEditPanel";
            editor.BlockTitle = string.Format("Your Custom Control {0}", BlockId);
        }
    }
}

In the ascx file add the following code.

 <%@ Register tagprefix="dsc" tagname="BlockEditor" src="/Controls/Blocks/BlockEditor.ascx" %>

 <dsc:BlockEditor id="editor" runat="server" />
<asp:Panel id="pnlBlockContent" runat="server">
    <%-- Place your control content here --%>
</asp:Panel>

A simple example is to check web\controls\blocks\Search.ascx and Search.ascx.cx files.

2) Hook up the new block in DB

Insert a new entry to dbo.DSC_Block_Type_lkp table e.g. INSERT INTO DSC_Block_Type_lkp (type, virtualPath) VALUES ('My Block', '/Controls/Blocks/MyBlock.ascx')

Insert a new entry to dbo.DSC_Block_Type_Group_Block_Type_Map

This technique will need to be updated for version 2.5.
It's has been updated.
Please read this blog entry for DotShoppingCart V2.5+.
Recent Comments
danny jones said ...
Hi... I am inexperiance to build up ECommenrce type sites.I have a little bits knowladge ...
molakaj said ...
What a great approach to the subject, I was looking for. Thanks for these tips http://www ...
jane said ...
Thank you for this useful information.
furnace parts said ...
Congrats on V4.0.....It is so easy to use  
Travis said ...
I just bought DSC Suite V4.5 and it is more solid then ever. I hope I am #1 buyer of this ...