Click here to Skip to main content
12,887,625 members (37,257 online)


QuestionCaution against using System.Drawing namespace in ASP.NET Pin
Abonet29-Sep-06 12:59
memberAbonet29-Sep-06 12:59 
QuestionActive Directory User Creation Pin
legionnaire29-Sep-06 12:07
memberlegionnaire29-Sep-06 12:07 
AnswerRe: Active Directory User Creation Pin
legionnaire2-Oct-06 5:51
memberlegionnaire2-Oct-06 5:51 
GeneralRe: Active Directory User Creation Pin
legionnaire2-Oct-06 6:24
memberlegionnaire2-Oct-06 6:24 
QuestionFile Download Response..... Pin
Bansari29-Sep-06 9:35
memberBansari29-Sep-06 9:35 
AnswerRe: File Download Response..... Pin
Jim Conigliaro29-Sep-06 10:45
memberJim Conigliaro29-Sep-06 10:45 
QuestionRe: File Download Response..... Pin
Bansari30-Sep-06 4:51
memberBansari30-Sep-06 4:51 
QuestionInherited TreeView Nodes and typeof Pin
perlmunger29-Sep-06 7:48
memberperlmunger29-Sep-06 7:48 
I am using an ASP.NET 2.0 TreeView and was wanting to create different child TreeNode types for the different items that I am loading into the treeview. The idea behind this is that all I should have to do is check the node type when a node gets clicked and I can then respond accordingly. The problem, however, is that the child treenode I created that inherits from TreeNode gets reported to be a normal TreeNode type rather than the inherited treenode type when I use the typeof operator even though I instantiate it as the child TreeNode type. Am I missing something?

class Child1TreeNode : TreeNode
class Child2TreeNode : TreeNode

And then in the Page Load:
protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack)
        Child1TreeNode node = new Child1TreeNode();
        node.Text = "Hello World";
        node.Value = "1";
        Child2TreeNode node2 = new Child2TreeNode();
        node2.Text = "Goodbye World";
        node2.Value = "2";
        TreeNode topNode = TreeView.FindNode("Top");
        topNode.ChildNodes.Add( node );

And then in the event handler for node changed:
protected void TreeView_SelectedNodeChanged(object sender, EventArgs e)
    TreeNode node = ((TreeView)sender).SelectedNode;
    if (node.GetType() == typeof(Child1TreeNode) )
        // Do something related to Child1TreeNode types
    else if (node.GetType() == typeof(Child2TreeNode) )
        // Do something related to Child2TreeNode types




The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall

AnswerRe: Inherited TreeView Nodes and typeof Pin
minhpc_bk29-Sep-06 15:03
memberminhpc_bk29-Sep-06 15:03 
GeneralRe: Inherited TreeView Nodes and typeof Pin
perlmunger30-Sep-06 9:29
memberperlmunger30-Sep-06 9:29 
GeneralRe: Inherited TreeView Nodes and typeof Pin
minhpc_bk1-Oct-06 2:43
memberminhpc_bk1-Oct-06 2:43 
QuestionTableAdapter info Pin
robert11029-Sep-06 7:40
memberrobert11029-Sep-06 7:40 
AnswerRe: TableAdapter info Pin
Mark Nischalke29-Sep-06 7:58
memberMark Nischalke29-Sep-06 7:58 
AnswerRe: TableAdapter info Pin
sanju027629-Sep-06 9:34
membersanju027629-Sep-06 9:34 
Questionphp Pin
amaneet29-Sep-06 6:39
memberamaneet29-Sep-06 6:39 
AnswerRe: php Pin
nguyenvhn29-Sep-06 16:24
membernguyenvhn29-Sep-06 16:24 
Questionphp Pin
amaneet29-Sep-06 6:25
memberamaneet29-Sep-06 6:25 
AnswerRe: php Pin
Mark Nischalke29-Sep-06 7:35
memberMark Nischalke29-Sep-06 7:35 
QuestionWeb Control Designing Questions Pin
Xiaoming Qian29-Sep-06 4:41
memberXiaoming Qian29-Sep-06 4:41 
QuestionKeeping focus on control after postback?? Pin
Goalie3529-Sep-06 3:54
memberGoalie3529-Sep-06 3:54 
AnswerRe: Keeping focus on control after postback?? Pin
postmaster@programmingknowledge.com29-Sep-06 4:48
memberpostmaster@programmingknowledge.com29-Sep-06 4:48 
AnswerRe: Keeping focus on control after postback?? Pin
Mark Nischalke29-Sep-06 5:38
memberMark Nischalke29-Sep-06 5:38 
AnswerRe: Keeping focus on control after postback?? Pin
amaneet29-Sep-06 6:29
memberamaneet29-Sep-06 6:29 
GeneralRe: Keeping focus on control after postback?? Pin
Mark Nischalke29-Sep-06 7:32
memberMark Nischalke29-Sep-06 7:32 
QuestionGridView RowCommand Pin
John Gathogo29-Sep-06 3:24
memberJohn Gathogo29-Sep-06 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 25 Apr 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid