Treeview SelectedNodeStyle Problem

Discussion in 'ASP .Net Web Controls' started by Sunny, Jul 3, 2006.

  1. Sunny

    Sunny Guest

    Hi,

    In my application, I use treeview inside a frame so when a tree node is
    clicked, it will direct to the main content only. I have set the
    selectednodeStyle with BackColor="Yellow", but when I selected the
    first node and then sleect another the back color is still yellow for
    the former one. The OnSelectedNodeChange event is never get fired.
    Below is my code excerpt:

    In TreePane.aspx

    <div>
    <asp:TreeView ID="TreeView1" runat="server"
    CollapseImageUrl="~/Images/treeMinus.gif"
    ExpandImageUrl="~/Images/treePlus.gif" Font-Names="Arial"
    Font-Size="8pt" ForeColor="Black"
    OnSelectedNodeChanged="OnSelectedNodeChange">
    <NodeStyle HorizontalPadding="10px" />
    <SelectedNodeStyle BackColor="Yellow" />
    <Nodes>
    <asp:TreeNode ImageUrl="~/Images/test1.ico"
    NavigateUrl="~/Management.aspx"
    Target="maincontent" Text="Management" Value="1">
    <asp:TreeNode NavigateUrl="~/Accounting.aspx"
    Target="maincontent" Text="Accounting"
    Value="3"></asp:TreeNode>
    </asp:TreeNode>
    <asp:TreeNode ImageUrl="~/Images/test2.ico"
    NavigateUrl="~/Customer Services.aspx"
    Target="maincontent" Text="Customer Services"
    Value="2"></asp:TreeNode>
    </Nodes>
    </asp:TreeView>
    </div>

    On the default page.aspx:

    <frameset frameborder="no" border="0" frameSpacing="0" frameBorder="0"
    cols="220" MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0"
    TOPMARGIN="0">
    <FRAMESET rows="30,*">
    <FRAME id="toolbar" src="HeaderPane.aspx" name="tooobar">
    <FRAMESET MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0"
    TOPMARGIN="0">
    <FRAMESET cols="200,*" framespacing="0" frameborder="yes"
    MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" TOPMARGIN="0">
    <FRAME id="leftmenu" src="TreePane.aspx" name="leftmenu">
    <frame id="maincontent" name="rightcontent" src="test1.aspx"
    name="rightcontent">
    </FRAMESET>
    </FRAMESET>
    </FRAMESET>
    </frameset>


    I would appreciate if anyone can help me with this problem.

    Thanks in advance,

    Sunny
     
    Sunny, Jul 3, 2006
    #1
    1. Advertising

  2. Sunny

    Bhuvana Guest

    Hi Sunny,

    The text of a node in the TreeView control can be in one of two modes:
    selection mode or navigation mode.
    When a node is in navigation mode, all selection events are disabled
    for that node. Clicking the node in navigation mode directs the user to
    the specified URL.

    You have used the NavigateUrl for all the nodes, so only
    OnSelectedNodeChanged is not getting fired.

    Refer this link for more information:
    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.treenode.aspx

    -Bhuvana
    [http://www.syncfusion.com/faq/aspnet/default.aspx]
     
    Bhuvana, Jul 4, 2006
    #2
    1. Advertising

  3. Sunny

    ValliM Guest

    Hi Sunny,

    As per your coding once you click the TreeNode its NavigateUrl property is
    executed , so that the OnSelectedNodeChange event is not getting fired. To
    get rid of it you could set the property programmatically , so that one
    TreeNode backcolor is alone changed.Remove the NavigationUrl property in the
    design mode and try with the function,
    protected void OnSelectedNodeChange(object sender, EventArgs e)

    {

    if (TreeView1.SelectedNode.Text == "Management")

    {

    TreeView1.SelectedNode.NavigateUrl="~/Management.aspx";

    }

    else if (TreeView1.SelectedNode.Text == "Accounting")

    {

    TreeView1.SelectedNode.NavigateUrl ="~/Accounting.aspx";

    }

    if (TreeView1.SelectedNode.Text == "Customer Services")

    {

    TreeView1.SelectedNode.NavigateUrl = "~/Customer Services.aspx";

    }

    }



    Regards,

    valli



    "Sunny" <> wrote in message
    news:...
    > Hi,
    >
    > In my application, I use treeview inside a frame so when a tree node is
    > clicked, it will direct to the main content only. I have set the
    > selectednodeStyle with BackColor="Yellow", but when I selected the
    > first node and then sleect another the back color is still yellow for
    > the former one. The OnSelectedNodeChange event is never get fired.
    > Below is my code excerpt:
    >
    > In TreePane.aspx
    >
    > <div>
    > <asp:TreeView ID="TreeView1" runat="server"
    > CollapseImageUrl="~/Images/treeMinus.gif"
    > ExpandImageUrl="~/Images/treePlus.gif" Font-Names="Arial"
    > Font-Size="8pt" ForeColor="Black"
    > OnSelectedNodeChanged="OnSelectedNodeChange">
    > <NodeStyle HorizontalPadding="10px" />
    > <SelectedNodeStyle BackColor="Yellow" />
    > <Nodes>
    > <asp:TreeNode ImageUrl="~/Images/test1.ico"
    > NavigateUrl="~/Management.aspx"
    > Target="maincontent" Text="Management" Value="1">
    > <asp:TreeNode NavigateUrl="~/Accounting.aspx"
    > Target="maincontent" Text="Accounting"
    > Value="3"></asp:TreeNode>
    > </asp:TreeNode>
    > <asp:TreeNode ImageUrl="~/Images/test2.ico"
    > NavigateUrl="~/Customer Services.aspx"
    > Target="maincontent" Text="Customer Services"
    > Value="2"></asp:TreeNode>
    > </Nodes>
    > </asp:TreeView>
    > </div>
    >
    > On the default page.aspx:
    >
    > <frameset frameborder="no" border="0" frameSpacing="0" frameBorder="0"
    > cols="220" MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0"
    > TOPMARGIN="0">
    > <FRAMESET rows="30,*">
    > <FRAME id="toolbar" src="HeaderPane.aspx" name="tooobar">
    > <FRAMESET MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0"
    > TOPMARGIN="0">
    > <FRAMESET cols="200,*" framespacing="0" frameborder="yes"
    > MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" TOPMARGIN="0">
    > <FRAME id="leftmenu" src="TreePane.aspx" name="leftmenu">
    > <frame id="maincontent" name="rightcontent" src="test1.aspx"
    > name="rightcontent">
    > </FRAMESET>
    > </FRAMESET>
    > </FRAMESET>
    > </frameset>
    >
    >
    > I would appreciate if anyone can help me with this problem.
    >
    > Thanks in advance,
    >
    > Sunny
    >
     
    ValliM, Jul 4, 2006
    #3
  4. Sunny

    Sunny Guest

    Hi Valli,

    Thank you for your reply. I tested out the change you suggested but I
    still have difficulty getting the highlight to highlight just the
    currently selected node. At present if I set the background color in
    the stylesheet, the highlight will not disappear when I select the new
    node. I want to have only the currentl7y selected node highlight
    (having the background color in yellow). Do you have any suggestion on
    how I should approach this problem?

    Sunny



    ValliM wrote:
    > Hi Sunny,
    >
    > As per your coding once you click the TreeNode its NavigateUrl property is
    > executed , so that the OnSelectedNodeChange event is not getting fired. To
    > get rid of it you could set the property programmatically , so that one
    > TreeNode backcolor is alone changed.Remove the NavigationUrl property in the
    > design mode and try with the function,
    > protected void OnSelectedNodeChange(object sender, EventArgs e)
    >
    > {
    >
    > if (TreeView1.SelectedNode.Text == "Management")
    >
    > {
    >
    > TreeView1.SelectedNode.NavigateUrl="~/Management.aspx";
    >
    > }
    >
    > else if (TreeView1.SelectedNode.Text == "Accounting")
    >
    > {
    >
    > TreeView1.SelectedNode.NavigateUrl ="~/Accounting.aspx";
    >
    > }
    >
    > if (TreeView1.SelectedNode.Text == "Customer Services")
    >
    > {
    >
    > TreeView1.SelectedNode.NavigateUrl = "~/Customer Services.aspx";
    >
    > }
    >
    > }
    >
    >
    >
    > Regards,
    >
    > valli
    >
    >
    >
    > "Sunny" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > In my application, I use treeview inside a frame so when a tree node is
    > > clicked, it will direct to the main content only. I have set the
    > > selectednodeStyle with BackColor="Yellow", but when I selected the
    > > first node and then sleect another the back color is still yellow for
    > > the former one. The OnSelectedNodeChange event is never get fired.
    > > Below is my code excerpt:
    > >
    > > In TreePane.aspx
    > >
    > > <div>
    > > <asp:TreeView ID="TreeView1" runat="server"
    > > CollapseImageUrl="~/Images/treeMinus.gif"
    > > ExpandImageUrl="~/Images/treePlus.gif" Font-Names="Arial"
    > > Font-Size="8pt" ForeColor="Black"
    > > OnSelectedNodeChanged="OnSelectedNodeChange">
    > > <NodeStyle HorizontalPadding="10px" />
    > > <SelectedNodeStyle BackColor="Yellow" />
    > > <Nodes>
    > > <asp:TreeNode ImageUrl="~/Images/test1.ico"
    > > NavigateUrl="~/Management.aspx"
    > > Target="maincontent" Text="Management" Value="1">
    > > <asp:TreeNode NavigateUrl="~/Accounting.aspx"
    > > Target="maincontent" Text="Accounting"
    > > Value="3"></asp:TreeNode>
    > > </asp:TreeNode>
    > > <asp:TreeNode ImageUrl="~/Images/test2.ico"
    > > NavigateUrl="~/Customer Services.aspx"
    > > Target="maincontent" Text="Customer Services"
    > > Value="2"></asp:TreeNode>
    > > </Nodes>
    > > </asp:TreeView>
    > > </div>
    > >
    > > On the default page.aspx:
    > >
    > > <frameset frameborder="no" border="0" frameSpacing="0" frameBorder="0"
    > > cols="220" MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0"
    > > TOPMARGIN="0">
    > > <FRAMESET rows="30,*">
    > > <FRAME id="toolbar" src="HeaderPane.aspx" name="tooobar">
    > > <FRAMESET MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0"
    > > TOPMARGIN="0">
    > > <FRAMESET cols="200,*" framespacing="0" frameborder="yes"
    > > MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" TOPMARGIN="0">
    > > <FRAME id="leftmenu" src="TreePane.aspx" name="leftmenu">
    > > <frame id="maincontent" name="rightcontent" src="test1.aspx"
    > > name="rightcontent">
    > > </FRAMESET>
    > > </FRAMESET>
    > > </FRAMESET>
    > > </frameset>
    > >
    > >
    > > I would appreciate if anyone can help me with this problem.
    > >
    > > Thanks in advance,
    > >
    > > Sunny
    > >
     
    Sunny, Jul 5, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VHltYm93?=
    Replies:
    2
    Views:
    24,542
    =?Utf-8?B?VHltYm93?=
    Jan 10, 2006
  2. =?Utf-8?B?Y3lyaWVsMTkyMEBub3NwYW0ubm9zcGFt?=

    ASP.NET Treeview selectedNodeStyle

    =?Utf-8?B?Y3lyaWVsMTkyMEBub3NwYW0ubm9zcGFt?=, Apr 14, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    6,699
    dany7487
    May 29, 2007
  3. AcuZod
    Replies:
    0
    Views:
    711
    AcuZod
    Apr 24, 2006
  4. =?Utf-8?B?SmFtZXMgSmVmZmVyaWVz?=

    SelectedNodeStyle.ImgURL bug?

    =?Utf-8?B?SmFtZXMgSmVmZmVyaWVz?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,061
    =?Utf-8?B?SmFtZXMgSmVmZmVyaWVz?=
    May 26, 2006
  5. Replies:
    0
    Views:
    3,127
Loading...

Share This Page