an ASP.NET Open Source CMS & eCommerce platform
Search:
Last Post 2/18/2008 9:16:45 AM By lukezy. 7 replies.
2/17/2008 7:45:50 PM
KM
Posts: 15
Joined: 2/4/2008
CMS Issue

<span>

Hi Luke :
Got an issue while playing with the CMS thing. Was trying to add one of those predefined section on my page, and I think I chose Menu , and
Now I have 2 menu showing on my default.aspx, and whenever I try to log in as admin to enable the page editor to fix that, I can't log in 
as following exception is thrown.  Can you please check what can be done ? 

Thanks
KM

Server Error in '/Web' Application. <hr width="100%" color="#c0c0c0" size="1" />

Multiple controls with the same ID 'Block_17' were found. FindControl requires that controls have unique IDs.

</span>

 

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Multiple controls with the same ID 'Block_17' were found. FindControl requires that controls have unique IDs.

Source Error:

<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</td> </tr> </tbody> </table>
Stack Trace:

<table width="100%" bgcolor="#ffffcc"> <tbody> <tr> <td>

[HttpException (0x80004005): Multiple controls with the same ID 'Block_17' were found. FindControl requires that controls have unique IDs.]
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +220
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +280
   System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +280
   System.Web.UI.Control.EnsureNamedControlsTable() +57
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +106
   System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +64
   System.Web.UI.Control.FindControl(String id) +9
   AjaxControlToolkit.ExtenderControlBase.FindControlHelper(String id) in D:\sites\DotShoppingCart\External\AjaxControlToolkit-Framework3.5\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:181
   AjaxControlToolkit.ExtenderControlBase.FindControl(String id) in D:\sites\DotShoppingCart\External\AjaxControlToolkit-Framework3.5\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:209
   System.Web.UI.ExtenderControl.RegisterWithScriptManager() +104
   System.Web.UI.ExtenderControl.OnPreRender(EventArgs e) +17
   AjaxControlToolkit.ExtenderControlBase.OnPreRender(EventArgs e) in D:\sites\DotShoppingCart\External\AjaxControlToolkit-Framework3.5\AjaxControlToolkit\ExtenderBase\ExtenderControlBase.cs:367
   System.Web.UI.Control.PreRenderRecursiveInternal() +86
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
</td> </tr> </tbody> </table>

2/17/2008 7:59:11 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: CMS Issue

This is known issue. Here is the private fix.

In web\controls\blocks\BlockContainer.ascx.cs

add the following line to the class variables.

    private Dictionary<int, int> blockIds = new Dictionary<int, int>();

replace the following to AddBlockToContainer method.

    private BlockUserControl AddBlockToContainer(int blockId, Control containerControls) {
        Block block = Block.GetById(blockId);
        if ((WebUtils.IsPageEditorEnable() && (!blockEditorDisabled) && (!EditorDisabled)) || CheckCondition(block.Conditions)) {
            BlockUserControl buc = (BlockUserControl)LoadControl(block.BlockType.VirtualPath);
            if (blockIds.ContainsKey(blockId)) {
                blockIds[blockId]++;
                buc.ID = string.Format("Block_{0}_{1}", blockId, blockIds[blockId]);
            } else {
                blockIds.Add(blockId, 1);
                buc.ID = string.Format("Block_{0}", blockId);
            }
            buc.BlockId = blockId;
            buc.BlockContainerId = BlockId;
            if (null != BlockContainerType)
                buc.BlockContainerType = BlockContainerType;
            buc.Data = block.Data;
            if (isFirstBlock)
                isFirstBlock = buc.MoveForwardEnabled = false;
            buc.EditorDisabled = EditorDisabled || blockEditorDisabled;
            Control controlToAdd = buc;
            if ((null == block.HeaderData) && (masterColumnWidth > 0)) {
                //Enable block header by default when inside master columns
                block.HeaderData = new BlockHeaderData() {
                    Enabled = true,
                    Height = 27,
                    Title = block.BlockType.Type,
                    Width = masterColumnWidth
                }.ToXElement();
            }
            if (null != block.HeaderData) {
                buc.HeaderData = Utils.FromXml<BlockHeaderData>(block.HeaderData.ToString());
                if (buc.HeaderData.Enabled) {
                    HtmlGenericControl blockDiv = new HtmlGenericControl("div");
                    blockDiv.Attributes.Add("class", "block");
                    HtmlGenericControl header = new HtmlGenericControl("div");
                    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);
                    blockDiv.Controls.Add(buc);
                    controlToAdd = blockDiv;
                }
            }
            containerControls.Controls.Add(controlToAdd);
            return buc;
        }
        return null;
    }

DotShoppingCart Staff
2/17/2008 8:51:56 PM
KM
Posts: 15
Joined: 2/4/2008
Re: CMS Issue

Great ! worked like a charm !
Thanks

 

2/17/2008 10:45:19 PM
KM
Posts: 15
Joined: 2/4/2008
Re: CMS Issue

Luke:

After making the changes, I removed my duplicated navigation menu.  But, then I can't add menu anymore. After trying to add the menu back using the CMS, it adds a block 17, but can't find the tabs for "HOME", and other tabs anymore. Any hints would be appreciated.

thanks

KM

2/17/2008 10:56:18 PM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: CMS Issue

I guess block 17 is just the block container which had a menu inside. You probably unfortunely deleted the menu inside the block 17. Try edit "block 17" using "Advanced" menu. If you see <div></div>, change it to <div>%%PlaceHolder1%%</div>. And then you should see the plus sign. Click it and then choose Menu. In menu edit page, enter "mainmenu" for CSS class and "tab" for Item CSS class and then add tabs for Home etc.

DotShoppingCart Staff
2/17/2008 11:55:12 PM
KM
Posts: 15
Joined: 2/4/2008
Re: CMS Issue

Thanks Luke:

THat brought back my menu, but the menus got detached from the Search bar, like half an inch above.  And can't bring it down next to the search bar. I'm sure missing something silly. :(

2/17/2008 11:57:31 PM
KM
Posts: 15
Joined: 2/4/2008
Re: CMS Issue

Also, forgot to post this earlier that, I tried to recreate the site from the downloaded zip file again, except using the same SQL database. and CMS issue came back too.  Is it keeping the CMS info in the SQL database ?

2/18/2008 9:16:45 AM
lukezy
Posts: 2109
Joined: 6/12/2007
Location:WA, US
Re: CMS Issue

Yes, most data are stored in DB other than several configuration setttings in DSC.config.

DotShoppingCart Staff