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

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.
 
J

Joern Schou-Rode

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/" />
 
G

Gregory A. Beamer

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top