Dynamic TreeView control in Master Page

Last post 11-01-2006 11:37 PM by akkus. 3 replies.

Sort Posts:

  • Dynamic TreeView control in Master Page

    10-31-2006, 10:22 PM
    • Member
      125 point Member
    • akkus
    • Member since 10-31-2006, 11:15 PM
    • Posts 32

    I have a treeview control (named MenuTree) in my master page. I need to generate it programmically depends on the user login. I have sitemap for generating the menu.

    How can I implement it using sitemap.
    I tried to create roles and attached the roles in <sitemapnode> but its not working.
    I tried to create a function for generating node automatically depends on the user login. Its working but the problem is, if I clicked on a particular node, it will display the corresponding page.

    for example:

     protected void MenuTree_SelectedNodeChanged(object sender, EventArgs e)
        {
            if (MenuTree.SelectedNode.Text == "Product")
            {
                 // Server.Transfer("Products/ProductStatus.aspx");
                 Response.Redirect("Products/ProductStatus.aspx");
            }
            else if (MenuTree.SelectedNode.Text == "Profile")
            {
                Server.Transfer("Profile/MyProfile.aspx");
            }
           
        }

    if I clicked on profile, it will display MyProfile.aspx in the first time. but if I click again in the same node, it is searching again Site/Profile/Profile/MyProfile.aspx.
    If I clicked on Product node, it is checking "Site/Profile/Products/ProductStatus.aspx.  It is not checking from root node.
    I tried to give relative path like ../Product/ProductStatus.aspx  and
    ~Site/Product/ProductStatus.aspx. but both are not working in some conditions.

    Any body has idea about it. pls help me.

    Filed under: ,
  • Re: Dynamic TreeView control in Master Page

    11-01-2006, 5:36 AM
    • Contributor
      2,209 point Contributor
    • pushp_aspnet
    • Member since 10-19-2006, 1:27 PM
    • Hyderabad,India
    • Posts 447

    Try:

     

     protected void MenuTree_SelectedNodeChanged(object sender, EventArgs e)
        {

          string root = System.Web.HttpContext.Current.Request.ApplicationPath.ToLower();


            if (MenuTree.SelectedNode.Text == "Product")
            {
                 Server.Transfer(root + "/Products/ProductStatus.aspx");
            }
            else if (MenuTree.SelectedNode.Text == "Profile")
            {
                Server.Transfer(root + "/Profile/MyProfile.aspx");
            }
           
        }

     

    Hope this helps.

    cheers!! 

    Home Is Where the Wind Blows
    http://pushpontech.blogspot.com
  • Re: Dynamic TreeView control in Master Page

    11-01-2006, 9:34 PM
    Answer
    • Member
      125 point Member
    • akkus
    • Member since 10-31-2006, 11:15 PM
    • Posts 32

    Yes Its working....Thanks

    May God bless you.

  • Re: Dynamic TreeView control in Master Page

    11-01-2006, 11:37 PM
    • Member
      125 point Member
    • akkus
    • Member since 10-31-2006, 11:15 PM
    • Posts 32

    There is some problem if you are using sitemapPath. It would not show exactly if you are using server.Transfer

    I modified

    Server.Transfer(root + "/Profile/MyProfile.aspx");

    to

    Response.Redirect(root + "/Profile/MyProfile.aspx");

    then the siteMapPath working properly

    Thanks

Page 1 of 1 (4 items)