Adding usercontrol as a Tool in the Toolbar

3 posts, 0 answers
  1. Amarjyoti
    Amarjyoti avatar
    5 posts
    Member since:
    Aug 2010

    Posted 10 Aug 2010 Link to this post


    I am trying to add a web user control(.ascx) in the RAD Toolbar. But the toolbar is not showing the user control. Can you please guide me where am i going wrong.

    Following is  my code snippet:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim paths() As String
            'Dim TaggerTemplate As TaggerTemplate

            Dim tlbBtn As RadToolBarButton
            tlbBtn = New RadToolBarButton("Tagger")
            tlbBtn.ItemTemplate = New TaggerTemplate()

            'TaggerTemplate = New TaggerTemplate
            'Dim item As RadToolBarItem = tlbBtn
            'item.ItemTemplate = New TaggerTemplate()


        End Sub

    Public Class TaggerTemplate
        Implements ITemplate

        Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
            Dim tagger As CtrlTagger

            tagger = New CtrlTagger
            tagger.ID = "TagItem"
            ' container.Controls.Add(tagger)

            Dim wrapperDiv As HtmlGenericControl = New HtmlGenericControl("DIV")
        End Sub

    End Class

  2. Yana
    Yana avatar
    4547 posts

    Posted 12 Aug 2010 Link to this post

    Hello Amarjyoti,

    You should use LoadControl method to add a user control, also the button should be added only on the first page load:

    If Not Page.IsPostBack Then
       Dim tlbBtn As RadToolBarButton
       tlbBtn = New RadToolBarButton("Tagger")
    End If
    Dim tagger As Control = LoadControl("test2.ascx")

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Amarjyoti
    Amarjyoti avatar
    5 posts
    Member since:
    Aug 2010

    Posted 14 Aug 2010 Link to this post

    Thanks Yana, it solved my problem.
Back to Top