Generally, the management system usually needs to use the permission management menu (whether to display, whether to enable), and the navigation tree control Treeview to form a flexible navigation control solution.
Masterpage is a good idea. You can place both the menu control and the Treeview control in it and provide corresponding data sources. If the menu does not change frequently (normally), you can make the menu and its sub-menus static, and the Treeview content is dynamically loaded according to the menu items.
Interface:
Code:
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Public partial class masterpageperson: system. Web. UI. masterpage
{
Protected void page_load (Object sender, eventargs E)
{
// Permission Control
If (session ["previlege"]. tostring () = "person ")
{
Menu1.enabled = false;
Menu2.visible = false;
Smsresultcheck. provider = system. Web. sitemap. Providers ["smpresultcheck"]; // menu3
}
Else
{
Menu1.enabled = true;
Menu2.visible = true;
Smsresultcheck. provider = system. Web. sitemap. Providers ["smpresultcheck"]; // menu3
}
// Configure the navigation tree content
If (session ["treevprovider"]! = NULL)
This. sitemapdatasource1.provider = system. Web. sitemap. Providers [session ["treevprovider"]. tostring ()];
Else
Smsresultcheck. provider = system. Web. sitemap. Providers ["smpresultcheck"];
}
Protected void menu1_menuitemclick (Object sender, menueventargs E)
{
Session ["treevprovider"] = "codemaintain ";
This. sitemapdatasource1.provider = system. Web. sitemap. Providers [session ["treevprovider"]. tostring ()];
}
Protected void menu2_menuitemclick (Object sender, menueventargs E)
{
String M = menu2.selecteditem. text;
If (M. Equals ("fund management "))
{
Session ["treevprovider"] = "projectprovider ";
This. sitemapdatasource1.provider = system. Web. sitemap. Providers [session ["treevprovider"]. tostring ()];
}
}
Protected void menu3_menuitemclick (Object sender, menueventargs E)
{
String M = menu3.selecteditem. text;
If (M. Equals ("department review "))
{
Session ["treevprovider"] = "smpresultcheckdepartment ";
This. sitemapdatasource1.provider = system. Web. sitemap. Providers [session ["treevprovider"]. tostring ()];
}
}
}
Run:
Of course, you need to configure web. config.
<Sitemap enabled = "true">
<Providers>
<Add name = "codemaintain" Description = "sitemap provider that reads in. sitemap files. "type =" system. web. xmlsitemapprovider, system. web, version = 2.0.3600.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "sitemapfile =" codemaintain. sitemap "/>
<Add name = "projectfee" Description = "sitemap provider that reads in. sitemap files. "type =" system. web. xmlsitemapprovider, system. web, version = 2.0.3600.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "sitemapfile =" projectworkflow. sitemap "/>
<Add name = "smpresultcheck" Description = "sitemap provider that reads in. sitemap files. "type =" system. web. xmlsitemapprovider, system. web, version = 2.0.3600.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "sitemapfile =" resultcheck. sitemap "/>
<Add name = "smpresultcheckdepartment" Description = "sitemap provider that reads in. sitemap files. "type =" system. web. xmlsitemapprovider, system. web, version = 2.0.3600.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a "sitemapfile = "~ /Resultcheck/departmentcheck. sitemap "/>
</Providers>
</Sitemap>