problem with menu control and sitemap

Last post 01-14-2008 2:34 AM by Amanda Wang - MSFT. 3 replies.

Sort Posts:

  • problem with menu control and sitemap

    01-11-2008, 5:22 AM
    • Participant
      1,382 point Participant
    • sunny74
    • Member since 10-20-2007, 7:47 PM
    • Posts 547

    Dear All,

    I am using  a menu control in a web app for the first time and I am getting strange kind of error.

    For creating and configuring the control on my web page I followed the instructions in this article:

    http://msdn2.microsoft.com/en-us/library/16yk5dby(VS.80).aspx

    I am using 2 menu controls, the first one displays level 1, level 2 of the sitemap while the second menu displays level 3 onwards.

    The error is as follows:

    Could not find the sitemap node with URL '~/users.aspx?'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Could not find the sitemap node with URL '~/users.aspx?'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [ArgumentException: Could not find the sitemap node with URL '~/users.aspx?'.]
       System.Web.UI.WebControls.SiteMapDataSource.GetNodes() +548
       System.Web.UI.WebControls.SiteMapDataSource.GetTreeView(String viewPath) +51
       System.Web.UI.WebControls.SiteMapDataSource.GetHierarchicalView(String viewPath) +171
       System.Web.UI.HierarchicalDataSourceControl.System.Web.UI.IHierarchicalDataSource.GetHierarchicalView(String viewPath) +32
       System.Web.UI.WebControls.HierarchicalDataBoundControl.GetData(String viewPath) +74
       System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +102
       System.Web.UI.WebControls.Menu.PerformDataBinding() +88
       System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +93
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
       System.Web.UI.WebControls.Menu.DataBind() +24
       System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +92
       System.Web.UI.WebControls.Menu.EnsureDataBound() +65
       System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +33
       System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript) +67
       System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) +49
       System.Web.UI.Control.PreRenderRecursiveInternal() +148
       System.Web.UI.Control.PreRenderRecursiveInternal() +233
       System.Web.UI.Control.PreRenderRecursiveInternal() +233
       System.Web.UI.Control.PreRenderRecursiveInternal() +233
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4437
    


    It can't find the file although it is there.

    Although I followed the instructions in the tutorial(link given above) my web.sitemap is different according to my needs. Initially my web.sitemap was as given below:

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
      <siteMapNode url="~/home.aspx" title="HOME"  description="HOME">
        <siteMapNode title="USERS"  description="USERS" >
          <siteMapNode url="~/users.aspx " title="USERS"  description="USERS HOME"/>
        </siteMapNode>
        <siteMapNode title="MASTERS"  description="MASTER'S HOME" >
          <siteMapNode url="~/mpassword.aspx " title="PASSWORD"  description="PASSWORD" />
          <siteMapNode url="~/bedmaster.aspx " title="BED MASTER"  description="BED MASTER" />
          <siteMapNode url="~/doctormaster.aspx " title="DOCTOR MASTER"  description="DOCTOR MASTER" />
          <siteMapNode url="~/refdoctormaster.aspx " title="REFERRING DOCTOR MASTER"  description="REFERRING DOCTOR MASTER" />
          <siteMapNode url="~/departmentmaster.aspx " title="DEPARTMENT MASTER"  description="DEPARTMENT MASTER" />
          <siteMapNode url="~/opdschmaster.aspx " title="OPD SCHEDULE MASTER"  description="OPD SCHEDULE MASTER" />
          <siteMapNode url="~/clinicmaster.aspx " title="CLINIC MASTER"  description="CLINIC MASTER" />
          <siteMapNode url="~/companymaster.aspx " title="COMPANY MASTER"  description="COMPANY MASTER" />
        </siteMapNode>
        <siteMapNode title="IPD HOME"  description="IPD HOME">
          <siteMapNode url="~/ipdpayment.aspx " title="IPD PAYMENT"  description="IPD PAYMENT" />
          <siteMapNode url="~/ipdlistofpatients.aspx " title="IPD LIST OF PATIENTS"  description="IPD LIST OF PATIENTS" />
          <siteMapNode url="~/hosporderforpharmacy.aspx " title="HOSPITAL ORDER FOR PHARMACY"  description="HOSPITAL ORDER FOR

    PHARMACY" />
          <siteMapNode url="~/ipdinfo.aspx " title="IPD INFORMATION"  description="IPD INFORMATION" />
          <siteMapNode url="~/ipddailycashcollection.aspx " title="IPD DAILY CASH COLLECTION"  description="IPD DAILY CASH

    COLLECTION" />
          <siteMapNode url="~/ipdbedstatus.aspx " title="IPD BED STATUS"  description="IPD BED STATUS" />
        </siteMapNode>
      </siteMapNode>
    </siteMap>

    Initially I had written the words node='filename' in the url of every link.Then I deleted it and my sitemap file looked like above.But after that I got the same error with only the node part missing.Then I  changed the sitemap file further and now it is as given below:

    <?xml version="1.0" encoding="utf-8" ?>

    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

    <siteMapNode url="~/home.aspx" title="HOME" description="HOME">

    <siteMapNode title="USERS" description="USERS" >

    <siteMapNode url="~/users.aspx " title="USERS" description="USERS HOME"/>

    </siteMapNode>

    <siteMapNode title="MASTERS" description="MASTER'S HOME" >

    <siteMapNode url="~/mpassword.aspx " title="PASSWORD" description="PASSWORD" >

    <siteMapNode url="~/passwordchange.aspx " title=" CHANGE PASSWORD" description="PASSWORD" />

    </siteMapNode>

    <siteMapNode url="~/bedmaster.aspx " title="BED MASTER" description="BED MASTER" >

    <siteMapNode url="~/bedprofiles.aspx " title="BED PROFILE" description="BED PFOFILE" />

    </siteMapNode>

    </siteMapNode>

    <siteMapNode title="IPD HOME" description="IPD HOME">

    <siteMapNode url="~/ipdpayment.aspx " title="IPD PAYMENT" description="IPD PAYMENT" >

    <siteMapNode url="~/paymentmain.aspx " title="PAYMENT" description="PAYMENT" />

    </siteMapNode>

    </siteMapNode>

    </siteMapNode>

    </siteMap>

      But the error remains.

    A solution to the problem would be gratefully accepted.

    Thanks.

    SUBHRANIL BASU RAY
    Mumbai

    TODAY'S TECHNIQUES ARE OBSOLETE FOR TOMORROW'S JOB.
    PLS MARK MY REPLY "AS ANSWER" IF IT HELPED YOU.
  • Re: problem with menu control and sitemap

    01-11-2008, 7:51 AM
    • Member
      38 point Member
    • stiduck
    • Member since 11-05-2007, 3:02 PM
    • Posts 4

    Hi presume you have tried without the ~/ ?

     

    Like: <siteMapNode url="users.aspx " title="USERS"  description="USERS HOME"/>

    Instead of: <siteMapNode url="~/users.aspx " title="USERS"  description="USERS HOME"/>

  • Re: problem with menu control and sitemap

    01-11-2008, 11:51 AM
    • Participant
      1,382 point Participant
    • sunny74
    • Member since 10-20-2007, 7:47 PM
    • Posts 547

    Hi,

    I followed your suggestion i.e removed ~/ from the URL paths.This resulted in the error NOT being shown.

    But I am not getting the desired output.I am getting to see the second level items i.e users,masters,ipd and Home.

    Home is level 1 item but it comes at the end of level 2. IF I click on masters link the error resurfaces this time the file name is mpassword.aspx.

    I feel this tutorial though a MSDN one is all wrong. Can you suggest a better one?

    Thanks.

    SUBHRANIL BASU RAY
    Mumbai

    TODAY'S TECHNIQUES ARE OBSOLETE FOR TOMORROW'S JOB.
    PLS MARK MY REPLY "AS ANSWER" IF IT HELPED YOU.
  • Re: problem with menu control and sitemap

    01-14-2008, 2:34 AM
    Answer

    Hi,

    1.Please check the users.aspx page is in the root directory, "~" represents the root directory. If the path is not corrrect, the error message will be thrown when you compile the application.

    Belwo is my test code by refering the MSDN article, during i create this test application, I met the same problem as you can, the cause of the problem is path of the page is not corrent, make the  second sitemapdatasource's StartingNodeUrl as the same as the sitemapnode's, and the check the page can be found by using this path.

    Now the below code, works fine on my local machine:

    1. the aspx code:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Menu_Cases_Cases_twomenu_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
       
            <asp:Menu ID="Menu1" runat="server" DataSourceID="SiteMapDataSource1"
                MaximumDynamicDisplayLevels="0" onmenuitemclick="Menu1_MenuItemClick"
                Orientation="Horizontal">
                <DataBindings>
                    <asp:MenuItemBinding DataMember="SiteMapNode" TextField="Title" />
                </DataBindings>
            </asp:Menu>
       
        </div>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
            ShowStartingNode="False" />
        <br />
        <br />
        <br />
        <asp:Menu ID="Menu2" runat="server" DataSourceID="SiteMapDataSource2"
            onmenuitemclick="Menu2_MenuItemClick" Orientation="Horizontal">
        </asp:Menu>
        <asp:SiteMapDataSource ID="SiteMapDataSource2" runat="server"
            EnableViewState="False" StartingNodeOffset="-1"
            StartingNodeUrl="~/Menu/Cases/Cases/twomenu/Default.aspx?node=hardware" />
        </form>
    </body>
    </html>

    2. the codebehind:

    protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
        {
            switch (e.Item.Value)
            {
                case "Products":
                    SiteMapDataSource2.StartingNodeUrl = "Default.aspx?node=hardware";
                    return;
                case "Services":
                    SiteMapDataSource2.StartingNodeUrl = "Default.aspx?node=consulting";
                    return;
                case "Support":
                    SiteMapDataSource2.StartingNodeUrl = "Default.aspx?node=drivers";
                    return;

            }
        }

    3.  the sitemap file:

    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">

      <siteMapNode title="Home">
        <siteMapNode title="Products">
          <siteMapNode title="Hardware" url="~/Menu/Cases/Cases/twomenu/Default.aspx?node=hardware">
            <siteMapNode title="Mouse"/>
            <siteMapNode title="Keyboard"/>
            <siteMapNode title="NetCard"/>
            <siteMapNode title="Monitor"/>
            <siteMapNode title="PC"/>
          </siteMapNode>
          <siteMapNode title="Software" url="Default.aspx?node=software">
            <siteMapNode title="Spreadsheet"/>
            <siteMapNode title="Word Processor"/>
            <siteMapNode title="Presentation"/>
            <siteMapNode title="Mail"/>
            <siteMapNode title="Games"/>
          </siteMapNode>
          <siteMapNode title="Books" url="Default.aspx?node=books">
            <siteMapNode title="Programming"/>
            <siteMapNode title="Debugging"/>
            <siteMapNode title="Testing"/>
            <siteMapNode title="Web Apps"/>
            <siteMapNode title="WinForm Apps"/>
          </siteMapNode>
        </siteMapNode>
        <siteMapNode title="Services">
          <siteMapNode title="Consulting" url="Default.aspx?node=consulting">
            <siteMapNode title="Processes"/>
            <siteMapNode title="Management"/>
            <siteMapNode title="Recruiting"/>
          </siteMapNode>
          <siteMapNode title="Development" url="Default.aspx?node=development">
            <siteMapNode title="Web Apps"/>
            <siteMapNode title="Enterprise Apps"/>
            <siteMapNode title="Database"/>
          </siteMapNode>
        </siteMapNode>
        <siteMapNode title="Support">
          <siteMapNode title="Drivers" url="Default.aspx?node=drivers">
            <siteMapNode title="Audio"/>
            <siteMapNode title="Network"/>
            <siteMapNode title="Printer"/>
            <siteMapNode title="Modem"/>
          </siteMapNode>
          <siteMapNode title="Manuals" url="Default.aspx?node=manuals">
            <siteMapNode title="Applications"/>
            <siteMapNode title="Troubleshooting"/>
            <siteMapNode title="Installation"/>
            <siteMapNode title="Internet"/>
          </siteMapNode>
          <siteMapNode title="Updates" url="Default.aspx?node=updates">
            <siteMapNode title="Release 1"/>
            <siteMapNode title="Game Package"/>
          </siteMapNode>
        </siteMapNode>
      </siteMapNode>

    </siteMap>

     

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)
Microsoft Communities