|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to Disabled node in TreeviewHello,
In my web application, i use a treeview control to navigate. I need to disabled node for Different roles. How to do this? Maria Paz,
This is a bit tricky scenario. This feature is not supported out-of-box with ASP.NET 2.0. I'm not sure how you can dynamically disable treeview nodes. But i've found a work around for this. Instead of populating you treeview with sitemap.xml, i populated with API's of Treeview. Using the API's you can add or remove nodes during the fly. You can use this as the base to set up the security trimming logic. Please refer the following snippet of code. hope this helps ! // Let's assume this is the snippet for the administrator and administrator // has access to all the nodes TreeNode tn1 = new TreeNode("First Node"); TreeView1.Nodes.Add(tn1); TreeNode tn2 = new TreeNode("Second Node"); TreeView1.Nodes.Add(tn2); TreeNode tn3 = new TreeNode("Third Node"); TreeView1.Nodes.Add(tn3); TreeNode tn4 = new TreeNode("Fourth Node"); TreeView1.Nodes.Add(tn4); // Lets assume this is the snippet for your under privileged user // You dont want to display the nodes 2 and t TreeView1.Nodes.Remove(tn2); TreeView1.Nodes.Remove(tn4); -- Show quoteHide quoteThanks & Regards, Mark Nelson "Maria Paz" wrote: > Hello, > In my web application, i use a treeview control to navigate. > I need to disabled node for Different roles. > How to do this? Thaks Mark.
But I found other solutions using a SiteMap and Treeview. I read Walkthrough: Filtering Site-Map Nodes Based on Security Roles in http://msdn2.microsoft.com/en-us/library/ms178429(vs.80).aspx Thanks again Show quoteHide quote "Mark Nelson" wrote: > Maria Paz, > > This is a bit tricky scenario. This feature is not supported out-of-box with > ASP.NET 2.0. I'm not sure how you can dynamically disable treeview nodes. > > But i've found a work around for this. Instead of populating you treeview > with sitemap.xml, i populated with API's of Treeview. Using the API's you can > add or remove nodes during the fly. You can use this as the base to set up > the security trimming logic. Please refer the following snippet of code. > > hope this helps ! > > // Let's assume this is the snippet for the administrator and > administrator > // has access to all the nodes > TreeNode tn1 = new TreeNode("First Node"); > TreeView1.Nodes.Add(tn1); > > TreeNode tn2 = new TreeNode("Second Node"); > TreeView1.Nodes.Add(tn2); > > TreeNode tn3 = new TreeNode("Third Node"); > TreeView1.Nodes.Add(tn3); > > TreeNode tn4 = new TreeNode("Fourth Node"); > TreeView1.Nodes.Add(tn4); > > // Lets assume this is the snippet for your under privileged user > // You dont want to display the nodes 2 and t > TreeView1.Nodes.Remove(tn2); > TreeView1.Nodes.Remove(tn4); > > > > > -- > Thanks & Regards, > Mark Nelson > > > "Maria Paz" wrote: > > > Hello, > > In my web application, i use a treeview control to navigate. > > I need to disabled node for Different roles. > > How to do this?
menu control StaticSelectedStyle
how to change email defined when creating account? ControlToValidate Script manager equivalent... How can I do? how to trigger action from button embedded in another control? Managed control and security problem with FindControl Error Creating Control CustomWebControls1 Unknown Server Tag cc1: CustomWebControls How can I select a row by clicking on ANY column Datagrid HeaderStyle.CssClass applied to <tr> |
|||||||||||||||||||||||