CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 10/23/2007 4:36:37 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 3 Views: 60 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
msalamon
Asp.Net User
SiteMapResolve event, global.asax and defaultProvider10/23/2007 4:36:37 PM

0/0

I am adding some custom behavior to the display of breadcrumbs. I had read many articles about adding an event handler in the global.axax Application_Start method to do this, as follows:

  SiteMap.Provider.SiteMapResolve += new SiteMapResolveEventHandler(CustomSiteMapHandler.Handle);

 (I have separately created the CustomSiteMapHandler class, but I could have done this within global.asax.)

I have gotten this to work perfectly, provided that the asp:SiteMapPath tag I am using to render the breadcrumbs references the default sitemap provider.  If it references any other provider listed in web.config, however, then the event handling code is skipped entirely.

 Can anyone confirm that the event handling only works with the default sitemap provider.  If this is not the case, can anyone show me how to have the event handling code work with a non-default provider.

RichardD
Asp.Net User
Re: SiteMapResolve event, global.asax and defaultProvider10/23/2007 6:22:17 PM

0/0

You need to add the event handler to all of the providers, not just the default provider: 
foreach (SiteMapProvider provider in SiteMap.Providers)
{
    provider.SiteMapResolve += CustomSiteMapHandler.Handle;
}
 
msalamon
Asp.Net User
Re: SiteMapResolve event, global.asax and defaultProvider10/23/2007 9:22:18 PM

0/0

Thanks.  I now understand what I was doing wrong.  However, I am still having some problems, likely in part b/c this is part of sharepoint.  My web.config looked like this, with the custom provider set as the default:

     <siteMap defaultProvider="CustomProvider" enabled="true"> <!-- CurrentNavSiteMapProvider   -->
      <providers>
        <add name="CustomProvider" siteMapFile="_app_bin/xyz.sitemap" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        <add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="true" />
     </providers>
     </siteMap>

 I changed my code in global.asax to this:

SiteMapProvider customSiteMapProvider = SiteMap.Providers["CustomProvider"];
customSiteMapProvider.SiteMapResolve += new SiteMapResolveEventHandler(Handle);

It all works fine.  but if I change my default provider to CurrentNavSiteMapProvider, then my global.asax throws this exception in the Handle() code:

  System.InvalidCastException: Unable to cast object of type 'System.Web.SiteMapNode' to type 'Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode'.

I put some logging code inside my Handle method:

SiteMapNode currentNode = SiteMap.CurrentNode; 
HttpContext.Current.Trace.Write("SiteMapProvider = " + currentNode.Provider.Name);

The site map provider that is always listed is the default sitemapprovider, regardless of which sitemapprovider i attached the event handler to.

Just added some more logging and found out something interesting.  currentNode.Provider.Name yields the default provider, but e.Provider (from SiteMapResolveEventArgs e) yields the custom provider.  Not sure what this means.... 

Thus, it appears as if the event handling code is still attached to the default (sharepoint) provider.  Any ideas?

 Thanks

msalamon
Asp.Net User
Re: SiteMapResolve event, global.asax and defaultProvider10/24/2007 3:34:04 PM

0/0

Oops.  I have answered my own question.  In the Handle() method I was getting the currentNode from the SiteMap object (the default one), not from the custom provider.  once I changed that, it worked fine.

4 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
SiteMapResolve event, global.asax and defaultProvider - ASP.NET Forums SiteMapResolve event, global.asax and defaultProvider. Last post 10-24-2007 11: 34 AM by msalamon. 3 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Wicked Code: Three Cures for Common Site Map Ailments The handler is named HandleUnmappedNodes. Figure 3 SiteMap.ResolveSiteMap Events in Global.asax ... SiteMapResolve events. SiteMap.SiteMapResolve += new ...
-[ Danny Chen ]- : An overview of how securityTrimmingEnabled is ... 1) Attach custom SiteMapResolve event handler method and inside check if ... 3) Attach some custom page event handler using HttpModule or global.asax and ...
Managing Site Navigation SiteMapResolve event is provided especially for. this type of scenario. .... add a Global.asax file to the web project.Within the Global.asax,you are going ...
TheMSsForum.com >> Asp >> Could not find schema messages won't ... I have tried to override SiteMapResolve event, but doesn't seem like i was on the ... The following works fine in an aspx file: global.asax: Public Shared ...
Adding synamic SiteMapNode - ASP.NET Forums You need to wire up an event in Global.asax ... SiteMapResolve += ( SiteMapHandler.SiteMap_SiteMapResolve); } ...
Andrei Ignat Blog - .NET Config sunt aceleasi - iar in global.asax trebuie pusa linia urmatoare: ..... The post build event on project – properties must be the same as for the ...
John Luif - Blog Post It was first set up in the Global.asax Application Start to check and create ...... To replace the default provider add the below lines to your web.config. ...
TheMSsForum.com >> Asp >> Could not find schema messages won't ... I have tried to override SiteMapResolve event, but doesn't seem like i was on the ... The following works fine in an aspx file: global.asax: Public Shared ...
Adding synamic SiteMapNode - ASP.NET Forums You need to wire up an event in Global.asax ... SiteMapResolve += ( SiteMapHandler.SiteMap_SiteMapResolve); } ...




Search This Site:










all rigths reserved - footer

dom problems with javascript

users roles information

an array of forms?

accessing updated control properties

sql problem , using select like

class libraries

need a bit of help getting started

can't get ibuyspy online...

how to create zip file using c#

override application root url

dnn4 solpart menu changes?

help with stopping access to previous page via browser back button

multiple server environment

possible adduser bug

css - overflow - fixee size - help - pleeezzzz???

is there an object that allows posting with relative path?

compiling before deployments aspx & aspx.cs

changing property based on event

guys help with session state

page

gallery module

secure connection to ldap server

user control gridview rowcommand not executing

adding pagename to a label in a usercontrol

web matrix

how to send form variables from one frame to another

can't update text

interactive form elements like java applet

xsd...

 
All Times Are GMT