newbie: menu / sitemap problem

J

Jeff

Hey

asp.net 2.0

My webportal consist of 2 menus (a header menu which goes horizontally
across the top of the page. And a sidebar menu to the left. The menuitmes
shown in the sidebar menu is dependent on what menuitem is selected in the
main menu.)

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="Home" description="">
<siteMapNode url="~/Network.aspx" title="Network" description="" >
<siteMapNode url="~/Search.aspx" title="Search" description="" />
<siteMapNode url="~/pageA.aspx" title="ItemA" description="" />
<siteMapNode url="~/pageB.aspx" title="ItemB" description="" />
</siteMapNode>
<siteMapNode url="" title="Forum" description="" />
</siteMapNode>
</siteMap>

When the "Network" menuitem in my main menu is clicked the sidebar menu
displays these menu items "Search", "ItemA", "ItemB". So now if the user
clicks on the "Search" menuitem in the sidebar menu, the sidebar menu
continue to display the same menuitems ("Search", "ItemA", "ItemB").

Problem:
In the "Search.aspx" file there is a button (btnSearch), which when clicked
executes this code:
protected void btnSearch_Click(object sender, EventArgs e)
{
Response.Redirect("~/Result.aspx?name=" + txtFullname.Text);
}

So when the result.aspx page is displayed. the sidebar menu is empty. I
think this must be related to using "Response.Redirect" to open the
"result.aspx" page. When the "result.aspx" page is opened. I want the
sidebar menu to continue to display the same menuitems ("Search", "ItemA",
"ItemB") as it did in the "search.aspx" page.

Any suggestions?

Jeff
 
G

Guest

I don't think that your problem has anything to do with the redirect.

You could try separating the
<siteMapNode url="~/Search.aspx" title="Search" description="" />
<siteMapNode url="~/pageA.aspx" title="ItemA" description="" />
<siteMapNode url="~/pageB.aspx" title="ItemB" description="" />

into a separate sitemap file and creating a new SitemapProvider that the
side menu would bind to (you can specify the sitemap file in the sitempa
definintion)

or
(and I haven't tried this myself)
The sitemap schema allows you to specify a provider or sitemap file on a
sitempa node. So what you might be able to do is:

<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="Default.aspx" title="Home" description="">
<siteMapNode url="~/Network.aspx" title="Network" description=""
siteMapFile="newFile.sitemap">
</siteMapNode>
<siteMapNode url="~/Result.aspx" title="Result" description=""
siteMapFile="newFile.sitemap">
</siteMapNode>
<siteMapNode url="" title="Forum" description="" />
</siteMapNode>
</siteMap>

Note that when the XMLSitemapProvider tries to find a node it search the
node list by url, including the querystring. This could cause you problems,
you may need to strore the name query string parameter in session.

Hope this helps,

Garth
 
J

Jeff

Thanks for replying so soon to my thread!

I don't quite understand (rememeber I'm a newbie) how this could solve my
problem. I mean I don't understand how putting the sidebar menuitems in it's
own sitemap file / provider could fix it... It works today with 1 sitemap
file and 1 provider. The problem is with the result.aspx page which is not
accessible through the menu. (currently not added to the sitemap, but could
add it if that is recommended)

Maybe I should have added that I based the configuration of my menus on
article: http://msdn2.microsoft.com/en-us/library/16yk5dby.aspx which shows
how to combine 2 menus, one menu dependent on the other menu.

When the user clicks on the "Network" menuitem in the main menu, the sidebar
menu displays "Search", "ItemA", "ItemB" menuitems. It continue to display
these menuitems when the user clicks on the "Search" menuitem in the sidebar
menu. It's only when the result.aspx file is displayed that the sidebar menu
shows no menuitems...

Any thoughts?

Jeff
 
J

Jeff

Jeff said:
Thanks for replying so soon to my thread!

I don't quite understand (rememeber I'm a newbie) how this could solve my
problem. I mean I don't understand how putting the sidebar menuitems in
it's own sitemap file / provider could fix it... It works today with 1
sitemap file and 1 provider. The problem is with the result.aspx page
which is not accessible through the menu. (currently not added to the
sitemap, but could add it if that is recommended)

Maybe I should have added that I based the configuration of my menus on
article: http://msdn2.microsoft.com/en-us/library/16yk5dby.aspx which
shows how to combine 2 menus, one menu dependent on the other menu.

When the user clicks on the "Network" menuitem in the main menu, the
sidebar menu displays "Search", "ItemA", "ItemB" menuitems. It continue to
display these menuitems when the user clicks on the "Search" menuitem in
the sidebar menu. It's only when the result.aspx file is displayed that
the sidebar menu shows no menuitems...

Any thoughts?

Jeff
 
G

Guest

Jeff,
Moving the side menu items into another sitemap wont fix your problem
directly but it will allow you to reuse those items as a submenu to the
results page if you add it as a sitemap node (the Network and Results nodes
point to the same file so if you change the sidew menu items its reflected in
both).

Can you post your settings for each of your SiteMapDataSources? (primarily
ShowStartingNode, StartFromCurrentNode, StartingNodeOffset and
StartingNodeUrl).

I'm thinking that adding the results page ot the sitemap will be problematic
due to the query string component added when you redirect. What you may be
able to do is set the side menu sitemap datasource StartingNodeUrl property
(if your using it as per the walkthrough) in the Page_Load of the
results.aspx.

Garth
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top