01-15-2013 07:54 AM - edited 01-15-2013 07:56 AM
We have multiple deployment targets for our SLX web app - development, QE, and production. One link in the toolbar menu needs to change depending on where the app is deployed to.
I have to compile it three times, once for each environment, each with the correct URL that I want the environment pointing to. Alternatively I can manually edit the control after deployment, but that is not practical. Instead I'd like to have it look at web.config.
Is it possible to configure an item in the Toolbar Menu to read values from web.config instead of hard-coding it via App Architect?
01-15-2013 08:59 AM
The menu service (IMenuService) can be used to modify the menu on the fly (add/remove/update). You could read values from appSettings.config (preferred) and update the menu accordingly.
Example of using the menu service:
var workSpace = this.PageWorkItem.Workspaces["ToolBar"] as ToolbarWorkspace; if (workSpace == null) return; var menuService = workSpace.WorkItem.Services.Get<IMenuService>(true); var mnuTools = menuService.FindMenu("mnuTools") as NavItemCollection; if (mnuTools == null) return; var navItemTest = new NavItem( "navTest", "Hello World", "Contact.aspx?mode=list", "~/ImageResource.axd?scope=global&type=Global_Images&key=Contacts_24x24", "~/ImageResource.axd?scope=global&type=Global_Images&key=Contacts_16x16" ); mnuTools.Add(navItemTest);
Note that if you need to modify the menu from all views on the fly (as opposed to code behind), you would probably have to create a module (i.e. assembly that implements IModule) and then modify the menu in the Load() method.