an ASP.NET Open Source CMS & eCommerce platform
Search:
Skip Navigation LinksHome > DotShoppingCart Blog > Customization
Customization
Add a Page Editor Enabled Custom Page to DotShoppingCart
Adding a custom page to DotShoppingCart is as simple as adding a page to any ASP.NET website. You can just create a page in folder that you like and start customizing your own content. If you wish to add a custom page that is integrated with DotShoppingCart e.g. page editor, theme etc, you will need to follow these steps.
 
1) Decide where you want to put the new page and create an entry in table DSC_Block_Type_lkp . And then retrieve the blockTypeId for the entry that has just been created.
e.g INSERT INTO DSC_Block_Type_lkp (Type, VirtualPath) VALUES ('My Page', '/Controls/Core/MyPage.ascx')
 
2) Add an entry to web\module.config to wire up the page url.
<add name="root" value="">
    <pages>
        <clear />
            <add name="MyPage" blockTypeId="99" />
    </pages>
</add>
 
3) Create a usercontrol under the path that you decided in step 1 e.g. web\controls\core\MyPage.ascx and make sure it's derived from PageBlockUserControl . You can take a look at any existing pages e.g. web\controls\UnSubscribe.ascx.cs for reference.
 
Add a Terms Agreement Checkbox In The Checkout Page
In Store\OnePageCheckout.ascx add the following code after the line "<div><h3><asp:Literal runat="server" text="<%$ Resources:Common,ReviewInformationAndSubmitOrder %>" /></h3></div>"
 
 
<div>
    <asp:CheckBox id="chkTerms" runat="server" text="I have read and agree the your terms." />
    <asp:CustomValidator id="cvdAgree" runat="server" clientvalidationfunction="IsChecked"
        onservervalidate="cvdAgree_ServerValidate" validationgroup="checkout" errormessage="The term agreement must be checked.">*</asp:CustomValidator>
    <script type="text/javascript">
        function IsChecked(obj, args) {
            var checkbox = $("#<%= chkTerms.ClientID %>");
            args.IsValid = checkbox.attr('checked');
        }
    </script>
</div>
 
 
In Store\OnePageCheckout.ascx.cs add the following code
 
     protected void cvdAgree_ServerValidate(object source, ServerValidateEventArgs args) {
        args.IsValid = chkTerms.Checked;
    }
Create Telerik alike menu in DotShoppingCart
I had one person asking how to implement Telerik alike menu in DotShoppingCart. In this post I will describe how you can use the dynamic image creating feature in DotShoppingCart along with some basic CSS tricks to archieve this.
 
1. Start off the Legacy Theme
 
2. Change Accent colors.
 
 
3. Update the menu CSS and add search box CSS in the Legacy Theme "App_Data\Themes\Themes_Template\Legacy\Default.css"
 
div.mainmenu div.tab a:link, div.mainmenu div.tab a:visited {
      background: url('/dyimage.axd?type=boxHeader&width=120&height=30&cornersize=0') no-repeat;
      float: left;
      margin-right: 1px;
      width: 120px;
      height: 30px;
      color: %Accent Fore Color%;
      font-weight: bold;
      text-decoration: none;
      text-align: center;
}
 
div.mainmenu div.tab a:active, div.mainmenu div.tab a.selected{
      background: url('/dyimage.axd?type=boxHeader&subtype=highlight&width=120&height=30&cornersize=0&gradient=False') no-repeat;
      color: %Accent Highlight Fore Color%;
}
 
div.mainmenu div.tab a:hover {
      background: url('/dyimage.axd?type=boxHeader&subtype=highlight&width=120&height=30&cornersize=0') no-repeat;
      color: %Accent Highlight Fore Color%;
}
 
td.searchBar {
    background: url('/dyimage.axd?type=boxHeader&width=1&height=30&cornersize=0') repeat;
    vertical-align: middle;
    padding-left:10px;
    border-right: solid 1px %Border Color%;
}
 
.searchShell {
    background:transparent url('/web/images/searchBoxBg.gif') no-repeat scroll 0;
}
 
.searchInputBox {
    height:13px;
    line-height:12px;
    margin-left:10px;
    padding:0;
    vertical-align:middle;
    width:172px;
    border:0 none;
}
 
.searchButton {
    background:transparent none repeat scroll 0 0;
    cursor:pointer;
    height:22px;
    vertical-align:middle;
    width:23px;
    border:0 none;
}
 
4. Update the search user control "Controls\Blocks\Search.ascx" to use the new search CSS.
 
<asp:Panel id="pnlBlockContent" runat="server">
    <div class="searchShell">
        <input type="text" class="searchInputBox" name="txtSearch" onkeydown="return GoSearch(event)" />
        <asp:Button id="btnDoSearch" runat="server" cssclass="searchButton" />
    </div>
</asp:Panel>
 
And finally you will get this.
 
 
Add a custom ASP.NET UserControl into the DotShoppingCart (V2.5+)
There was an old blog entry talking about adding custom ASP.Net user control to DotShoppingCart. From DotShoppingCart V2.5 the page editor has been rewritten by using JQuery. As the result the way to integrate the custom ASP.NET user control is simplified.
 
1) Create a Standard ASP.NET stardard User Control and derive it from BlockUserControl
 
Check "Web/View/Blocks/TagCloud.ascx.cs" for the example.
 
using DotShoppingCart.Commercial.Core;
public partial class View_Blocks_TagCloud : BlockUserControl {
 
2) Hook up the new block type in DB
 
    a) 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')
 
    b) Insert a new entry to dbo.DSC_Block_Type_Group_Block_Type_Map
 
e.g. INSERT INTO DSC_Block_Type_Group_Block_Type_Map (BlockTypeGroupId, BlockTypeId, SortOrder) VALUES (3, <id that is created in step a>, 10)
 
To add your custom user control to page, just enable page edior and click "+" sign. Find the custom block in the proper group (which you add in the step b above).
Customize Product Summary Grid
DotShoppingCart allows you to customize the product summary easily. To do that just go to any product summary page and enable the page editor. Click "Edit" in the dropdown menu of the product summary block. See the image below.
 
 
Update the html code in "Product Summary Template". Notice there are tokens wrapped by %% e.g. %%ProductName%%. These tokens will be replaced by the product properties during the runtime.
 
 
Replace Dynamic Block Header Background With the Customized Static Image
In DotShoppingCart themes and skins are dynamic. When you change the colors in site admin, all the images in the themes are created again by using GDI+ API.
 
Check the areas surrounded by the red rectangles below. These background images are created dynamically.
 
and
 
 
The bottom ones are called block headers. This article describes how you can replace the block headers with your customized static images.
 
The css class for the block headers is "blockHeader". If you search the "blockHeader" against your entire solution, you will find one in Default.css
 
div.blockHeader {
    text-align:center;
      font-weight: bold;
}
 
div.blockHeader a {
      text-decoration: none;
}
 
and the other one in web/controls/blocks/BlockContainer.ascx.cs.
 
header.Attributes.Add("class", "blockHeader");
header.Attributes.Add("style", string.Format(BlockHeaderFormat, buc.HeaderData.Height - 6, buc.HeaderData.Width, buc.HeaderData.Height));
header.InnerText = buc.HeaderData.Title;
blockDiv.Controls.Add(header);
 
To use your customized static image as the block header background, please do
 
1) Add your background image to the div.blockHeader css style e.g. background-image:url(<your image url>);
2) Remove the code adding the inline style
header.Attributes.Add("style", string.Format(BlockHeaderFormat, buc.HeaderData.Height - 6, buc.HeaderData.Width, buc.HeaderData.Height));
 
Here is an example of the customzed header blocker.
 
 
Use Advanced Menu in Block Container to Achieve Another Layer of Customization
After you enable page editor, you will find a special menu item "Adavanced" in the dropdown menu of any block container. After you click it, you will see a warning sign "Note: please stop if you don't know HTML! Do not touch anything inside %% or you will get your site screwed up." As the general rule, if you are not familar with the raw HTML editing then please don't use this feature. Also you don't want to touch anything wrap around %%.
Disable or remove certain UI pieces

I had people asking how to disable some UI pieces in some pages. Here are some detail questions and my answers.

1) how do I disable the action buttons e.g. "Ask a Question", "Update Alert", "Tell a Friend" in product detail page?

In web\store\ProductAction.aspx, find <asp:ImageButton id="btnAskQuestion", <asp:ImageButton id="btnUpdateAlert", <asp:ImageButton id="btnTellFriend" and put visible="false" inside the tag.

2) Remove register link

In web\controls\blocks\LoginMenu.ascx, remove line <li><a href="<%=SiteNavigation.RegisterPage %>">Register</a></li>.

In web\controls\core\Login.ascx, remove these lines.

<td class="logincell">

    <asp:Button id="btnRegister" runat="server" text="Create New Account" />
</td>

In web\controls\core\Login.ascx.cs, remove these lines.

btnRegister.OnClientClick = string.Format("window.open('{0}{1}', '_self'); return false;",

    SiteNavigation.RegisterPage, string.IsNullOrEmpty(returnUrl) ? "" : "?ReturnUrl=" + returnUrl);

3) Remove customer Reviews in product detail page

In web\store\Product.aspx, remove those lines

<tr>

    <td colspan="2">
         <dsc:ProductReviews id="prvReview" runat="server" />
    </td>
</tr>

In web\store\Product.aspx.cs, remove those lines

prvReview.Product = product;
prvReview.DataBind();

4) Remove Redeem Gift Certificate in shopping cart page

In web\store\Cart.aspx, find <asp:Panel id="pnlGiftCertificate" runat="server"> and put visible="false" inside the tag.

 

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

Customize Checkout Page

I had many people asking how to add return policy or other information to the checkout page. Here is the video shows how to do it.

Customize Category List Block
Default Category List Block The default implementation of category list block is giving your store shopper the smart product navigation. When shopper selects a category, the category opens up its sub categories and usefully links like narrow by price ranges or narrow by manufacturers etc. The remaining top level categories move to the bottom.

In this article I show you one way of customizing your own category list block. One of our customers wanted to show the top level categories initially. When shopper clicks one top level category, its sub categories expand. Click the same category again to collapse the sub categories. Here is the code archiving this.

You can download the full code for V3 and code fro V2.

Use dynamic image creation to make site easy to customize

Often times web site design involves image design such as buttons and box header etc. If you want to show a gradient color and make it compatible to all the browsers, you'd better start doing graphic design images. All these have made web site design a much harder to enter for average non-technical site owners. Part of the goals of DotShoppingCart is to enable non-technical people to easy use the software and turn it into a good looking e-commerce web site.

We have built several themes inside DotShoppingCart. The theme can be further customized such as changing colors and the sizes of building blocks such as side boxes. Normally when a theme consists of image buttons and image header bars, you cannot change the image button colors or the size of building blocks unless you re-draw these images by using the graphic design software. To resolve this problem we used the Windows GDI+ API to create image buttons dynamically based on the colors and sizes that you wish to customize. So in the end you first pick up a theme that you like and then further customize the overall looking by adjusting the colors and sizes of the building blocks. Within one click and "Crtl -F5" in the browse (complete refresh hot-key in IE), all the images defined in the theme are created on the fly.

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 ...