Welcome Guest Search | Active Topics | Sign In | Register

SlideMenu - dynamically adding controls Options
Posted: Saturday, August 11, 2007 7:27:31 AM
Rank: Newbie
Groups: Member

Joined: 8/11/2007
Posts: 1
Hi ,

I'm trying to construct menu that will display list of products. For each product in a collection top menu item should be created (which does work), but in each SlidePane (SubMenu item) user control should be loaded during the runtime, or instance of this control could be customized.

Code below is not displaying SlidePane, because collection is not hierarchical (correct me if I'm wrong). Do you know how this can be resolved, so I could render the content of MyUserControl for each product in the SlidePane.

VB.NET Code

Code: Visual Basic.NET
menu.DataSource = Product.GetAll()
        menu.DataBind()


ASPX Page:

Code: HTML/ASPX
<eo:SlideMenu ID="menu" runat="server"  DataFields="ProductName" SlidePaneHeight="200"
            ExpandEmptyPane="true" >
    <TopGroup  >
        <Items>
		<eo:MenuItem  >
			  <SubMenu  >
    			<Items >
				 <eo:MenuItem CustomItemId="MyControl" ></eo:MenuItem>
			   </Items>
			</SubMenu>
		   </eo:MenuItem>
		</Items>
	</TopGroup>



Code: HTML/ASPX
<eo : CustomItem runat="server" ID="MyControl">
    <uc2:MyUserControl ID="Test" runat="server"  /> 
 </eo:CustomItem>



From my point of view that would be the ideal scenario:

Code: Visual Basic.NET
Dim menuItemForFirstProduct As New MenuItem
        Dim customItem As New CustomItem()
        customItem.Controls.Add(LoadControl("MyUserControl.ascx"))
        testMenuItem.CustomItem = customItem

        menu.Items(0).SubMenu.Items.Add(menuItemForFirstProduct)


TIA,

Max
eo_support
Posted: Saturday, August 11, 2007 8:11:20 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Max,

You won't be able to set the item's CustomItem property because that property actually takes an ITemplate object, not a CustomItem object. The ITemplate object is supplied by ASP.NET compiler at runtime.

However your original code that sets CustomItemID would work. I would try these steps:

1. Start with a fixed static menu and a fixed static CustomItem with a few regular controls, such as a Lable, a TextBox, do not put a UserControl in it. That should work;
2. Try change the static menu into a dynamically created menu (or dynamically created item) and see if it works;
3. Try add your user control into CustomItem and see if it works;

This way we should be able to narrow down the problem to a specific step. We can then try to find a solution from there.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.