Click here to Skip to main content
15,891,943 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCaution against using System.Drawing namespace in ASP.NET Pin
Peter Josefsson Sweden29-Sep-06 12:59
Peter Josefsson Sweden29-Sep-06 12:59 
QuestionActive Directory User Creation Pin
legionnaire29-Sep-06 12:07
legionnaire29-Sep-06 12:07 
AnswerRe: Active Directory User Creation Pin
legionnaire2-Oct-06 5:51
legionnaire2-Oct-06 5:51 
GeneralRe: Active Directory User Creation Pin
legionnaire2-Oct-06 6:24
legionnaire2-Oct-06 6:24 
QuestionFile Download Response..... Pin
Neo7869229-Sep-06 9:35
Neo7869229-Sep-06 9:35 
AnswerRe: File Download Response..... Pin
Jim Conigliaro29-Sep-06 10:45
Jim Conigliaro29-Sep-06 10:45 
QuestionRe: File Download Response..... Pin
Neo7869230-Sep-06 4:51
Neo7869230-Sep-06 4:51 
QuestionInherited TreeView Nodes and typeof Pin
perlmunger29-Sep-06 7:48
perlmunger29-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
minhpc_bk29-Sep-06 15:03 
GeneralRe: Inherited TreeView Nodes and typeof Pin
perlmunger30-Sep-06 9:29
perlmunger30-Sep-06 9:29 
GeneralRe: Inherited TreeView Nodes and typeof Pin
minhpc_bk1-Oct-06 2:43
minhpc_bk1-Oct-06 2:43 
QuestionTableAdapter info Pin
robert11029-Sep-06 7:40
robert11029-Sep-06 7:40 
AnswerRe: TableAdapter info Pin
Not Active29-Sep-06 7:58
mentorNot Active29-Sep-06 7:58 
AnswerRe: TableAdapter info Pin
sanju027629-Sep-06 9:34
sanju027629-Sep-06 9:34 
Questionphp Pin
amaneet29-Sep-06 6:39
amaneet29-Sep-06 6:39 
AnswerRe: php Pin
nguyenvhn29-Sep-06 16:24
nguyenvhn29-Sep-06 16:24 
Questionphp Pin
amaneet29-Sep-06 6:25
amaneet29-Sep-06 6:25 
AnswerRe: php Pin
Not Active29-Sep-06 7:35
mentorNot Active29-Sep-06 7:35 
QuestionWeb Control Designing Questions Pin
Xiaoming Qian29-Sep-06 4:41
Xiaoming Qian29-Sep-06 4:41 
QuestionKeeping focus on control after postback?? Pin
Goalie3529-Sep-06 3:54
Goalie3529-Sep-06 3:54 
AnswerRe: Keeping focus on control after postback?? Pin
postmaster@programmingknowledge.com29-Sep-06 4:48
postmaster@programmingknowledge.com29-Sep-06 4:48 
AnswerRe: Keeping focus on control after postback?? Pin
Not Active29-Sep-06 5:38
mentorNot Active29-Sep-06 5:38 
AnswerRe: Keeping focus on control after postback?? Pin
amaneet29-Sep-06 6:29
amaneet29-Sep-06 6:29 
GeneralRe: Keeping focus on control after postback?? Pin
Not Active29-Sep-06 7:32
mentorNot Active29-Sep-06 7:32 
QuestionGridView RowCommand Pin
John Gathogo29-Sep-06 3:24
John 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.