Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 508223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:53:07+00:00 2026-05-13T06:53:07+00:00

I extended treeview, treenode, and nodetype so I could have custom nodes. Certain nodes

  • 0

I extended treeview, treenode, and nodetype so I could have custom nodes. Certain nodes have image buttons on them allowing them to add a child node or delete the node. I can’t handle any of the events from my buttons.

Public Class ContentTreeView
Inherits TreeView

Public Event OnAddChild(ByVal sender As Object, ByVal e As EventArgs)
Public Event OnDelete(ByVal sender As Object, ByVal e As EventArgs)

Private _AddImageURL As String = String.Empty
Private _DeleteImageURL As String = String.Empty

Public Property AddImageURL() As String
    Get
        Return _AddImageURL
    End Get
    Set(ByVal value As String)
        _AddImageURL = value
    End Set
End Property

Public Property DeleteImageURL() As String
    Get
        Return _DeleteImageURL
    End Get
    Set(ByVal value As String)
        _DeleteImageURL = value
    End Set
End Property

Protected Overrides Function CreateNode() As TreeNode
    Dim retval As ContentTreeNode = New ContentTreeNode(AddImageURL, DeleteImageURL)
    AddHandler retval.OnAddChild, AddressOf ContentNode_AddChild
    AddHandler retval.OnDelete, AddressOf ContentNode_Delete
    Return retval
End Function

Protected Sub ContentNode_AddChild(ByVal sender As Object, ByVal e As EventArgs)
    RaiseEvent OnAddChild(Nothing, Nothing)
End Sub
Protected Sub ContentNode_Delete(ByVal sender As Object, ByVal e As EventArgs)
    RaiseEvent OnDelete(Nothing, Nothing)
End Sub

Public Class ContentTreeNode
    Inherits TreeNode

    Public Event OnAddChild(ByVal sender As Object, ByVal e As EventArgs)
    Public Event OnDelete(ByVal sender As Object, ByVal e As EventArgs)

    Private _AddImageURL As String = String.Empty
    Private _DeleteImageURL As String = String.Empty

    Private btnAddChild As ImageButton
    Private btnDelete As ImageButton

    Public Sub New(ByVal AddImageURL_ As String, ByVal DeleteImageURL_ As String)
        _AddImageURL = AddImageURL_
        _DeleteImageURL = DeleteImageURL_
    End Sub

    Public Property AddImageURL() As String
        Get
            Return _AddImageURL
        End Get
        Set(ByVal value As String)
            _AddImageURL = value
        End Set
    End Property

    Public Property DeleteImageURL() As String
        Get
            Return _DeleteImageURL
        End Get
        Set(ByVal value As String)
            _DeleteImageURL = value
        End Set
    End Property

    Protected Overrides Sub RenderPreText(ByVal writer As HtmlTextWriter)
    End Sub

    Protected Overrides Sub RenderPostText(ByVal writer As HtmlTextWriter)
        CreateChildControls()
        If GetTreeNodeType() <> ContentTreeNodeTypes.Root Then
            btnAddChild.RenderControl(writer)
            If GetTreeNodeType() <> ContentTreeNodeTypes.Category Then
                btnDelete.RenderControl(writer)
            End If
        End If
    End Sub

    Private Function GetTreeNodeType() As TreeNodeTypes
        Dim leaf As TreeNodeTypes = TreeNodeTypes.Leaf
        If ((Me.Depth = 0) AndAlso (Me.ChildNodes.Count > 0)) Then
            Return ContentTreeNodeTypes.Root
        End If
        If Me.Depth = 1 Then
            Return ContentTreeNodeTypes.Category
        End If
        If ((Me.ChildNodes.Count <= 0) AndAlso Not Me.PopulateOnDemand) Then
            Return leaf
        End If
        Return ContentTreeNodeTypes.Parent
    End Function

    Protected Sub CreateChildControls()
        'Controls.Clear()

        '***Creat Add Button***
        btnAddChild = New ImageButton()
        btnAddChild.ID = "btnAddChild"
        btnAddChild.ImageUrl = AddImageURL
        btnAddChild.ToolTip = "Add Child"
        AddHandler btnAddChild.Click, AddressOf btnAddChild_Click

        '***Create DeleteButton***
        btnDelete = New ImageButton()
        btnDelete.ID = "btnDelete"
        btnDelete.ImageUrl = DeleteImageURL()
        btnDelete.ToolTip = "Delete Page"
        AddHandler btnDelete.Click, AddressOf btnDelete_Click

        ''***Add Controls***
        'Me.Controls.Add(btnAddChild)
        'Me.Controls.Add(btnDelete)
    End Sub

    Protected Sub btnAddChild_Click(ByVal sender As Object, ByVal e As EventArgs)
        RaiseEvent OnAddChild(Nothing, Nothing)
    End Sub
    Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As EventArgs)
        RaiseEvent OnDelete(Nothing, Nothing)
    End Sub


    Public Enum ContentTreeNodeTypes
        All = 7
        Leaf = 4
        None = 0
        Parent = 2
        Root = 1
        Category = 3
    End Enum
End Class

End Class

1) Can I implement something like IPostBackEventHandler?
2) Is this possible since treeNode isn’t a control/webcontrol?

Any help is appreciated… Thanks!!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:53:07+00:00Added an answer on May 13, 2026 at 6:53 am

    After reading this post. I decided to use the following solution. First I changed my CreateChildControls method to:

            Protected Sub CreateChildControls()
            Dim page As Page = HttpContext.Current.CurrentHandler
            Dim csm As ClientScriptManager = page.ClientScript
            Dim control As WebControl = page.Master.FindControl(_ContainerID).FindControl(_ContentTreeViewID)
    
            '***Creat Add Button***
            btnAddChild = New ImageButton()
            btnAddChild.ID = "btnAddChild"
            btnAddChild.ImageUrl = AddImageURL
            btnAddChild.ToolTip = "Add Child"            
            btnAddChild.Attributes.Add("onClick", csm.GetPostBackEventReference(control, String.Format("{0}:{1}", Me.Value, "Add")))
    
            '***Create DeleteButton***
            btnDelete = New ImageButton()
            btnDelete.ID = "btnDelete"
            btnDelete.ImageUrl = DeleteImageURL()
            btnDelete.ToolTip = "Delete Page"
            btnDelete.Attributes.Add("onClick", csm.GetPostBackEventReference(control, String.Format("{0}:{1}", Me.Value, "Delete")))
        End Sub
    

    Then I had to implement IPostBackEventHandler in the custom treeview to handle the postback events. Maybe not the best solution but it works well with custom event args.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have extended Ext.data.Operation to implement a custom commitRecords method. The Ext.data.Operation class is
I have an extended from BaseAdapter class which used as a custom Adapter for
I have extended std::string to fulfil my needs of having to write custom function
I have a TreeView with nodes, so when I click on one of the
I extended JDialog to create a custom dialog where the user must fill some
In my extended PreferenceActivity class I call addPreferencesFromResource(R.xml.livewallpaper_settings) so I have a xml file
I have extended SimpleCursorAdapter and am running into a weird issue with bindView, which
I extended the Nokogiri::HTML:Document class as follows to add a function called on_same_line? module
I extended a ModelAdmin with a custom field Download file, which is a link
I have succesfully extended a view and overridden the onDraw() method I can draw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.