asp.net - multiple SiteMap nodes with same URL with querystring parameters -


in sitemap control using, want 2 or more of nodes point same page.

 <sitemapnode url="~/default.aspx" title="home"  description="home page">   <sitemapnode url="~/sectionlist.aspx" title="by section"  description="list of sections">     <sitemapnode url="~/browsepublications.aspx" title="publications of section"  description="publications of section"/>   </sitemapnode>   <sitemapnode url="~/officers.aspx" title="by responsible officer"  description="list of officers">     <sitemapnode url="~/browsepublications.aspx" title="publications of officer"  description="publications of officer"/>   </sitemapnode> </sitemapnode> 

i have grid show, grid can filtered in many ways. each filter page user clicks entry , gets redirected page showing grid data relevant entry. using query string parameters achieve that. read online 1 way overcome limitation append dummy parameters or '#' end of urls of duplicate nodes, tried this

 <sitemapnode url="~/default.aspx" title="home"  description="home page">   <sitemapnode url="~/sectionlist.aspx" title="by section"  description="list of sections">     <sitemapnode url="~/browsepublications.aspx?view=2" title="publication view 1"  description="publication view"/>   </sitemapnode>   <sitemapnode url="~/officers.aspx" title="by responsible officer"  description="list of officers">     <sitemapnode url="~/browsepublications.aspx?view=3" title="publication view"  description="publication view"/>   </sitemapnode> </sitemapnode> 

and using hashes, since redirecting browsepublications.aspx query parametrs, ( url

browsepublications.aspx?view=2&c=24

asp.net did not recognize , got exception when tried accessing sitemap.currentnode browsepublications.aspx easiest way achieve this. thanks

i struggled while have asked. there effective , easier way have 2 same urls(with different query strings) in different sitemap nodes. thought post solution in future benefit it.

firstly need parent node , parent parent node present in sitemap.

<sitemapnode title="" description="" url="" >         <sitemapnode title="parentparenttest2" description="" url="~/parentparenttest2.aspx" >                   <sitemapnode title="parenttest2" description="" url="~/parenttest2.aspx" >            <sitemapnode title="page_that_needs_to_be_in_multiple_nodes" description="" url="~/xyz.aspx" />              </sitemapnode>         </sitemapnode>          <sitemapnode title="parentparenttest2" description="" url="~/parentparenttest2.aspx"  >            <sitemapnode title="parenttest2" description="" url="~/parenttest2.aspx"> ////you don't have add ~/xyz.aspx  node again. if add multiple node exception.            </sitemapnode>          </sitemapnode>       </sitemapnode>  //copy code in master page page_load event sitemap.sitemapresolve += sitemap_sitemapresolve; 

///add event handler master page.

  public sitemapnode sitemap_sitemapresolve(object sender, sitemapresolveeventargs e)             {                 //get current node                 sitemapnode currentnode = sitemap.currentnode;                 if (currentnode != null)                 {                     currentnode = sitemap.currentnode.clone(true);                     sitemapnode tempnode = currentnode;                           sitemapnode nnewnode = new sitemapnode(e.provider,tempnode.key);                         switch (tempnode.key)                         {                             case "/test1.aspx":                                     nnewnode.clone(true);                                      nnewnode.parentnode.parentnode.readonly = false;                                     nnewnode.parentnode.readonly = false;                                if(querystring["page"]="test1")     {                                         nnewnode.parentnode.parentnode = sitemap.provider.findsitemapnodefromkey("~/parentparenttest1.aspx");                                      nnewnode.parentnode = sitemap.provider.findsitemapnodefromkey("~/parenttest1.aspx");                                     nnewnode.parentnode.readonly = false;                                     nnewnode.parentnode.url = "~/parenttest1.aspx?statesave=true";                                     nnewnode.parentnode.title = httpcontext.current.request.querystring["parentnodename"];                                     nnewnode.title = httpcontext.current.request.querystring["currentnodename"];     }      if (querystring["page"]="test2")     {     //copy same code , replace test1 test2.     }      // returning newly prepared node.                                                      return nnewnode;                             default: break;                          }                      }                  }                  return currentnode;              }  

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -