Click here to Skip to main content
12,354,122 members (71,083 online)
   

ASP.NET

 
QuestionGet N words of a string Pin
shapper29-Sep-06 14:45
membershapper29-Sep-06 14:45 
AnswerRe: Get N words of a string Pin
Mark Nischalke29-Sep-06 15:39
memberMark Nischalke29-Sep-06 15:39 
GeneralRe: Get N words of a string Pin
Guffa29-Sep-06 22:51
memberGuffa29-Sep-06 22:51 
GeneralRe: Get N words of a string Pin
shapper30-Sep-06 2:13
membershapper30-Sep-06 2:13 
AnswerRe: Get N words of a string Pin
Guffa1-Oct-06 8:49
memberGuffa1-Oct-06 8:49 
GeneralRe: Get N words of a string Pin
Mark Nischalke30-Sep-06 2:53
memberMark Nischalke30-Sep-06 2:53 
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
    }
}
Thanks.

-Matt







------------------------------------------

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 
AnswerRe: GridView RowCommand Pin
Satips29-Sep-06 3:49
memberSatips29-Sep-06 3:49 
AnswerRe: GridView RowCommand Pin
Kschuler29-Sep-06 11:08
memberKschuler29-Sep-06 11:08 
Questionmailto: Issue Pin
ma se29-Sep-06 2:34
memberma se29-Sep-06 2:34 
AnswerRe: mailto: Issue Pin
Paddy Boyd29-Sep-06 2:47
memberPaddy Boyd29-Sep-06 2:47 
QuestionAccess Data Source > Loop Pin
shapper29-Sep-06 2:24
membershapper29-Sep-06 2:24 
AnswerRe: Image refresh in a page Pin
albCode29-Sep-06 2:42
memberalbCode29-Sep-06 2:42 
QuestionImage refresh in a page Pin
Uma Kameswari29-Sep-06 2:19
memberUma Kameswari29-Sep-06 2:19 
AnswerRe: Image refresh in a page Pin
Satips29-Sep-06 2:41
memberSatips29-Sep-06 2:41 
GeneralRe: Image refresh in a page Pin
Uma Kameswari29-Sep-06 2:46
memberUma Kameswari29-Sep-06 2:46 
GeneralRe: Image refresh in a page Pin
Satips29-Sep-06 2:54
memberSatips29-Sep-06 2:54 
AnswerRe: Image refresh in a page Pin
Paddy Boyd29-Sep-06 2:53
memberPaddy Boyd29-Sep-06 2:53 
QuestionQueryString Function Pin
John Gathogo29-Sep-06 2:05
memberJohn Gathogo29-Sep-06 2:05 
AnswerRe: QueryString Function Pin
Guffa29-Sep-06 2:38
memberGuffa29-Sep-06 2:38 
GeneralRe: QueryString Function Pin
John Gathogo29-Sep-06 3:51
memberJohn Gathogo29-Sep-06 3:51 
Questionweb part for share point Pin
indrani2229-Sep-06 1:58
memberindrani2229-Sep-06 1:58 
AnswerRe: web part for share point Pin
Satips29-Sep-06 2:35
memberSatips29-Sep-06 2:35 
QuestionQueryString Pin
Vsree29-Sep-06 1:52
memberVsree29-Sep-06 1:52 
AnswerRe: QueryString Pin
Apurva Kaushal29-Sep-06 1:58
memberApurva Kaushal29-Sep-06 1:58 
GeneralRe: QueryString Pin
Vsree29-Sep-06 2:00
memberVsree29-Sep-06 2:00 

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.160621.1 | Last Updated 28 Jun 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid