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





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 8/3/2006 8:12:08 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 12 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
gopalav
Asp.Net User
Change sitemap attributes in runtime and store sitemap in cache8/3/2006 8:12:08 PM

0/0

Hi!

I'm working on storing and displaying the navigation in my project.  The following is the present scenario.

  1. the navigation data is in multiple xml files
  2. the xml files are read and the details are stored in two classes awform and awforms(collection class).  the awform class has properties to store url, title etc.
  3. manipulate the enabled, visible properties of the awform class in the code behind
  4. and finally render the links using a user control.  It reads the awforms collection class and displays the link according to their properties like title, url, enabled and visible

Now i want to get rid of all these and use the sitemap file to store the data and let the user control directly talk to sitemap and display the contents.  So far everything is fine.  But if i want to make changes to properties in memory for ex: the enabled custom property will change in runtime, how do i do that?  Also i want to store the sitemap into a cache and use a file dependency on the sitemap file.  Can i store the sitemap in cache?

I really appreciate your time on this.

Dave Sussman
Asp.Net User
Re: Change sitemap attributes in runtime and store sitemap in cache8/4/2006 8:51:11 AM

0/0

You can modify SiteMapNde properties at run time - the SiteMap is a global property of the page, allowing you access to the nodes. However, the data isn't cached so the provider is called for many operations, meaning you'd have to keep changing. One way around this is to use a SiteMapResolve event, which you hook into in global.asax; SiteMapResolve is called each time a node is requested, so you can override the properties and return the new node. Search for Danny Chen's blog - he's got an example of this.

If you want to do caching then you really need to write your own site map provider. Search MSDN for the SiteMapProvider - all of the source for the providers supplied with ASP.NET is freely available on MSDN.

Dave

gopalav
Asp.Net User
Re: Change sitemap attributes in runtime and store sitemap in cache8/4/2006 4:47:16 PM

0/0

Thanks Dave.  I found that if i change the Readonly property of the node to false, i'm able to change the title property.  But my main requirement is to change the custom attributes like enabled, visible etc and also persist them in some form to share across different pages.  We used collection classes to store the sitemap node properties and used to operate on the properties.  Similarly i would like to change the sitemap node properties and be able to store the object in session.  I'm not able to change the custom attributes even if set the Readonly property to false.  So my questions are

1. Can I change the custom attributes in sitemap resolve event? Is there any other way to change the custom attributes.

2. Can I put the RootNode object into cache and retrieve it later?  I will also create a file dependency on the sitemap file for this cache.  Will that work?  I tested it and it seems to work.  I just want to double check with you.

Thanks a lot

 

Dave Sussman
Asp.Net User
Re: Change sitemap attributes in runtime and store sitemap in cache8/7/2006 8:13:09 AM

0/0

1. SiteMapResolve is called after the node is returned from the provider and you return a SiteMapNode from this method. So, you can construct a new node, with new properties and just return that. You can cache these too if you need to.

2. Yes, the RootNode can be cached. In fact any node can be cached, but it's worth understanding how the sitemap framework works in this regard. Every navigational UI control will either call the SiteMapDataSource or the Provider directly (in the case of the SiteMapPath), each time it needs node details. Effectively this means every page and for each node. Thus caching just the root node won't bring you create speed improvements. However, if the reason for caching is simply to create the file dependency, then yes that's fine.

Dave

gopalav
Asp.Net User
Re: Change sitemap attributes in runtime and store sitemap in cache8/9/2006 8:05:17 PM

0/0

Hi Dave!

Let me list my requirements again!!

1) I want to store the hierarchy in a sitemap file. done

2) I want to add custom attributes for each node. done

3) And store this in a session object for that user.

4) I want to edit these attributes in runtime.  For ex: if the user selects a particular item in a dropdown box in one page, i need to disable/hide another page in the sitemap.  For that i need to edit the "enabled" and "visible" attributes in runtime.  We are using QuickRules.Net to enable/hide different links in the sitemap. 

For ex: I want to do something like this: 

void ActivateForm(string key)
{
   SessionSiteMap.RootNode.ChildNodes[1]["enabled"] = "true";
}
Where SessionSiteMap is the copy of the original SiteMap stored in a session for this user.

5) And then use this sitemap directly with a treeview or other navigation controls.

6) We have two navigations in the website, a treeview like navigation where we do hide/disable certain links and a horizontal prev/next like wizard where we only navigate to enabled and visible links.

So all I need is a collection of sitemapnodes on which i can operate and change the attributes and store it in a session to share it across pages. As per your reply, we can change the custom attributes in a sitemapresolve event but my main problem is to remember the changes across pages.

I thought of using the sitemap class so that i can automatically fill in the sitemap contents and i can navigate through the hierarchy.  But if i cannot change the custom attributes and save it in the session, i have to write a custom class which simulates this behaviour.  I want to use the existing classes which provide this hierarchial behaviour and then extend that.

Any help is greatly appreciated.

 

 

 

 
Dave Sussman
Asp.Net User
Re: Change sitemap attributes in runtime and store sitemap in cache8/10/2006 8:21:13 AM

0/0

There are only two places you can change the nodes: the first is in the provider and the second is in the SiteMapResolve event. Nodes are requested from the provider when:

1. A SiteMapDataSource is in use and a control is bound to it

2. A SiteMapPath is in use.

Both of these utilse the FindSiteMapNode method in the provider and the resolve event is raised after that. You want to modify the menu structure based upon user selections, which is not what the framework is designed to to.

I think your best bet is to actually write a new provider. This way you can control which nodes are surfaced to the UI. The code for the existing providers is freely available from MSDN (search http://weblogs.asp.net/scottgu - he posted about the code some time ago). Within the provider, when constructing the nodes, you can then make decisions based upon the user and current state of the application.

Dave

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



Search This Site:


Meet Our Sponsors:



Other Resources:

Seeking some tips with video. - macromedia.flash - Web Programming ... Seeking some tips with video., > ROOT > NEWSGROUP > Adobe-Macromedia Forums > macromedia.flash, Date: 1/29/2008 ... change sitemap attributes in runtime and ...
Amazon.com: "runtime requests": Key Phrase page ... Server, Web Design, navigational attributes, data warehouse layer, staging ... View or change your orders in Your Account. Shipping & Returns ...
Site Map Providers You wish to store site map data in an XML file whose schema differs from that of the ... and change site map nodes on the fly by responding to a site map ...
Amazon.com: "outputcache directive": Key Phrase page Built-in Editors 285 TABLE 9-1: OutputCache Directive Attributes 294 ... property, cache dependency, skin file, site map file, end user clicks, catalog mode, ...
New ASP.NET 2.0 SQL Site Map Provider - ScottGu's Blog ... the tags because some attributes in the menu node will be ... I believe this will automatically invalidate the cache when the database contents change. ...
ASP.NET.4GuysFromRolla.com: Examining ASP.NET 2.0's Site Navigation ... ... accessing site map data through the SiteMap class; includes ... to build it once and cache this tree until there's some file system-level change. ...
Custom Site Map Providers in ASP.NET 2.0 ... method, and then read any custom attributes defined and store these ... Role management, and the SiteMap, without needing to change the user interface. ...


 
All Times Are GMT