How to set NavigateUrl of an asp:MenuItem when moving from QA toPROD?

  • Thread starter Thread starter MDaisy
  • Start date Start date
M

MDaisy

It is customary that the MenuItem NavigateUrl values either in a
sitemap file or in a database.
However, unfortunately, the consulting company that is developing the
software package for the company that I work for has all menu items
inline and hard-coded.
I cannot change their menu implementation because they won't let me
change it.

Anyway, there is currently a menu item called Tools and under it there
is a Search menu item
I need to add an additional menu item with a NavigateUrl that points
to SQL Server Report Manager so it changes when going from dev, to
qa and to prod.
Question: Is there a way for me to code a key in appsettings section
of web.config and plug it as NavigateUrl for my additional menu item?
web.config can be edited when promoting to another environment without
having to compile the application.

The menu is hard-coded in the master page of the entire web
application.
<asp:MenuItem Text="Tools" Selectable="false" >

<asp:MenuItem Text="Search" NavigateUrl="~/
Search.aspx"></asp:MenuItem>

thank you.
 
Question: Is there a way for me to code a key in appsettings section
of web.config and plug it as NavigateUrl for my additional menu item?
web.config can be edited when promoting to another environment without
having to compile the application.

In your markup (page or user control):
<asp:MenuItem Text="Reports" NavigateUrl="<%$ AppSettings:ReportServerUrl
%>" />

In your web.config, in the appSettings section:
<add key="ReportServerUrl" value="http://example.org/" />
 
It is customary that the MenuItem NavigateUrl values either in a
sitemap file or in a database.
However, unfortunately, the consulting company that is developing the
software package for the company that I work for has all menu items
inline and hard-coded.
I cannot change their menu implementation because they won't let me
change it.

Anyway, there is currently a menu item called Tools and under it there
is a Search menu item
I need to add an additional menu item with a NavigateUrl that points
to SQL Server Report Manager so it changes when going from dev, to
qa and to prod.
Question: Is there a way for me to code a key in appsettings section
of web.config and plug it as NavigateUrl for my additional menu item?
web.config can be edited when promoting to another environment without
having to compile the application.

The menu is hard-coded in the master page of the entire web
application.
<asp:MenuItem Text="Tools" Selectable="false" >

<asp:MenuItem Text="Search" NavigateUrl="~/
Search.aspx"></asp:MenuItem>

thank you.


Jeorn has given you a way to hard code in pointers. Another way to
accomplish this is to create your own custom provider to feed the menu.
I would personally opt for the custom direction in most cases, as it is
more flexible and better decouples the UI from the data. If you do not
expect any changes in the basic flow of the menu, however, it may be
overkill, esp. the first time (due to learning curve).


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top