asp.net - Query string paramaters for a sitemap -
asp.net - Query string paramaters for a sitemap -
i'm using vwd 2010, asp.net, c#. have sitemap works, need able link external sites , send parameters. found code looks should work, i'm missing kind of understanding or seem assuming know don't. (the other fellow seems have understood perfectly.)
revised: adding show how menu , sitedatasource declared.
            <asp:sitemapdatasource runat="server" id="sitemapdatasource" showstartingnode="false" />              <asp:menu id="navigationmenu" runat="server" cssclass="menu" datasourceid="sitemapdatasource"                 enableviewstate="false" includestyleblock="false" orientation="horizontal"                  backcolor="#f7f6f3" dynamichorizontaloffset="2" font-names="verdana"                  font-size="0.8em" forecolor="#7c6f57" staticsubmenuindent="10px">                 <dynamichoverstyle backcolor="#7c6f57" forecolor="white" />                 <dynamicmenuitemstyle horizontalpadding="5px" verticalpadding="2px" />                 <dynamicmenustyle backcolor="#f7f6f3" />                 <dynamicselectedstyle backcolor="#5d7b9d" />                 <dynamicitemtemplate>                     <%# eval("text") %>                 </dynamicitemtemplate>                 <statichoverstyle backcolor="#7c6f57" forecolor="white" />                 <staticmenuitemstyle horizontalpadding="5px" verticalpadding="2px" />                 <staticselectedstyle backcolor="#5d7b9d" />             </asp:menu>    note menu works extent correctly displays info in web.sitemap.
here's link original code: http://weblogs.asp.net/jgaylord/adding-querystring-parameters-to-the-sitemapnode
my sitemap works, doesn't seem invoking extended sitemapprovider. i'm sure provider doesn't need...at point i'm trying create sure it's getting invoked. so, set breaks in code in initialize() , in the smartsitemapprovider_sitemapresolve() routine. i'm trying invoke when think should invoke @ point. can't modify if can't debug it, , can't debug it, if can't invoked.
i'm using c# code , have duplicated below. have set in it's own class file @ top level called extendedsitemapprovider.cs
here's section web.config i'm using.
<sitemap enabled="true" defaultprovider="extendedsitemapprovider">   <providers>     <clear/>     <add name="extendedsitemapprovider" type="configuration.extendedsitemapprovider" sitemapfile="web.sitemap" securitytrimmingenabled="true" />   </providers> </sitemap>    the c# code site.
using system; using system.collections.generic; using system.collections.specialized; using system.linq; using system.web;  using system.web.ui; using system.web.ui.webcontrols; using system.web.ui.webcontrols.webparts; using system.web.sessionstate;  namespace configuration {     public class extendedsitemapprovider : xmlsitemapprovider     {         public override void initialize(string name, namevaluecollection attributes)         {             base.initialize(name, attributes);              this.sitemapresolve += smartsitemapprovider_sitemapresolve;         }          static sitemapnode smartsitemapprovider_sitemapresolve(object sender, sitemapresolveeventargs e)         {             if ((sitemap.currentnode == null))  homecoming null;             sitemapnode temp = sitemap.currentnode.clone(true);             sitemapnode tempnode = temp;               while (tempnode != null)             {                 string qs = getquerystring(tempnode, e.context);                  if (qs != null)                 {                     tempnode.url += qs;                 }                  tempnode = tempnode.parentnode;             }               homecoming temp;         }          private static string getquerystring(sitemapnode node, httpcontext context)         {             if (node["querystringtoinclude"] == null)  homecoming null;              namevaluecollection values = new namevaluecollection();              string[] vars = node["querystringtoinclude"].split(",".tochararray());              foreach (string s in vars)             {                 string var = s.trim();                 if (context.request.querystring[var] == null) continue;                 values.add(var, context.request.querystring[var]);             }              if (values.count == 0)  homecoming null;               homecoming namevaluecollectiontostring(values);         }          private static string namevaluecollectiontostring(namevaluecollection col)         {             string[] parts = new string[col.count];             string[] keys = col.allkeys;              (int = 0; <= keys.length - 1; i++)             {                 parts[i] = keys[i] + "=" + col[keys[i]];             }               homecoming "?" + string.join("&", parts);         }     }  }       
it looks though should work. set breakpoint in page_load, , when   nail it, have @ navigation  command properties. instance,  come in sitemappath1 in immediate window. provider property either xmlsitemapprovider, or, if it's working, extendedsitemapprovider.
if breakpoint in  page_load not   nail either, answer--you're somehow not running in debug mode. :)
 asp.net sitemap querystringparameter sitemapprovider 
 
Comments
Post a Comment