Adding a Content Template to Dynamically Created Menu Item

4 posts, 0 answers
  1. Support
    Support avatar
    7 posts
    Member since:
    Apr 2010

    Posted 15 Sep 2014 Link to this post

    I have a basic menu created successfully, but would like to have a template applied to a couple dynamically created items.

    I would like to have a User Control be the contents so that the management of the content can be controlled separately.

    So my basic scenario is this:

    Create Root Menu item, Create Sub item, Apply ItemTemplate, Create New Sub Item, Undo Template...

    My Template is such:


    'ItemTemplate Class. Just pulls the User Control
    Class QC_HACCP_Hold
            Implements ITemplate
            Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
                Dim lit1 As New QC_HACCP_Hold_Lot
                container.Controls.Add(lit1)
            End Sub
        End Class
     
     
    'User Control write up - QC_HACCP_Hold_Lot
     
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="QC_HACCP_Hold_Lot.ascx.vb" Inherits="sadlersnet.QC_HACCP_Hold_Lot" %>
    <asp:panel id="pnlHold" runat="server">
        <p>
            Enter Lot Number to Place on Hold<br />
            <asp:TextBox ID="txtLotNumber" runat="server"></asp:TextBox><asp:Button ID="cmdHoldLot" runat="server" Text="Set to Hold" />
        </p>
    </asp:panel>
     
    'Code to Create Parent and Sub with Template Applied
            Dim _QCHACCP_Place_Lot_On_Hold As RadMenuItem = AddMenuItem("Place Lot on Hold", Nothing, False)
            With _QCHACCP_Place_Lot_On_Hold
                Dim _QC_HoldTemplate As New Custom_Rad_Templates.QC_HACCP_Hold
                mnuMain.ItemTemplate = _QC_HoldTemplate
                .Items.Add(New RadMenuItem)
       
            End With
     
    'Helper function for creating menuitems
    Private Function AddMenuItem(ByVal Caption As String, URL As String, ByVal AutoPostBack As Boolean, Optional ByVal Target As String = Nothing) As RadMenuItem
            Dim _MenuItem As RadMenuItem = New RadMenuItem
            _MenuItem.PostBack = AutoPostBack
            _MenuItem.NavigateUrl = URL
            _MenuItem.Text = Caption
            If Not IsNothing(Target) Then _MenuItem.Target = Target
            Return _MenuItem
        End Function

    Im getting the Parent and it knows theres a sub, and expanding just gives me a little tiny box with no content...

    Any Ideas?
  2. Support
    Support avatar
    7 posts
    Member since:
    Apr 2010

    Posted 15 Sep 2014 Link to this post

    Addendum. I have changed the code to include the InstatiateIn:
    With _QCHACCP_Place_Lot_On_Hold
                Dim _QC_HoldTemplate As New Custom_Rad_Templates.QC_HACCP_Hold
                mnuMain.ItemTemplate = _QC_HoldTemplate
                .Items.Add(New RadMenuItem)
            End With

    This still does not change the outcome...unfortunately
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Support
    Support avatar
    7 posts
    Member since:
    Apr 2010

    Posted 15 Sep 2014 Link to this post

    Scratch prev post..cut and paste did not work right:

    Correct Change
    With _QCHACCP_Place_Lot_On_Hold
                Dim _Template As New Custom_Rad_Templates.QC_HACCP_Hold
                Dim _X As New RadMenuItem
                _Template.InstantiateIn(_X)
                .Items.Add(_X)
            End With
  5. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 18 Sep 2014 Link to this post

    Hi,

    There is a problem with the dynamic creating of the Content Template for the RadMenu control. Currently it could be defined only from the markup.

    Regards,
    Dimitar Terziev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top