Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

In the Trenches

Joe's Thoughts

SiteMapPath navigation control for ASP.NET 2.0

What can I say, I’m sure many of you have put this to use, though here I want to publicly complain about a couple issues.

 

For one it would have been nice if there was some event that got clicked when one clicked a link. That could have been handled much like how my solution would show.

 

The other thing is support for a simple target, yep; you can put in a link but not say a target. Now how annoying is that? I don’t think the guys that developed this control even had framesets on their mind at all.

 

Well to my solution.

 

It’s rather simple when you think about it, I used the standard method of using this control, and that’s in union with a web.sitemap xml file.

 

I then did this to the node in question.

<siteMapNode url="BLOCKED SCRIPTOpenHome();" title="HOME" description="" >

Now all that’s cool and all notice it opens home. Well my problem and why I had to come up with this solution is that one of the pages in the application required frames. Yes I could have purchased or did my own little splitter control or something but in the end, all browsers understand framesets (was having trouble with JS in different browsers).

 

Plus this was only for one single part of the application which isn’t publicly exposed.

 

Also note I did this with master page with the sitemappath control on that page. So I then just put this little JS script on the master page and all was well.

 

<script language="javascript" type="text/javascript">

 

 

if (self.location.href.indexOf("PageInFrameThatUsesMasterPage.aspx")< 0)

 

{

 

if (self != top) {

 

    top.location.href = self.location.href;

 

}

 

}

 

 

function OpenHome()

 

{

 

top.location.href = "http://www.google.com";

 

}

 

</script>

 

Now the script above makes it so I don’t break out of frames on the one page that I don’t want to break out. Now of course I could have just made a small function that takes a string for the URL that I put in the XML. That would have made it even smaller. This is the first draft solution that worked ok for me.

 

That’s it, nice and simple, though I didn’t find many answer out there on my problem. I couldn’t use my break out code on the home page since it was another site all together, hence I didn’t have control of that site. Plus don’t try onunload event, that fires on every refresh and postback.

 

Enjoy

 

Joe

Published Friday, October 06, 2006 10:30 AM by jfuentes

Comments

No Comments
Anonymous comments are disabled

About jfuentes

Jose Fuentes is the Co-Founder of the Capital City .NET Users Group of Florida, he helped organized and build the community and community web site (www.tlhdotnet.net). He’s an active MVP (Most Valuable Professional) for Microsoft, and strongly involved in the .NET community. He gives presentations and loves helping others with problems. You can find many of his posts and work on www.aspalliance.com, www.planet-source-code.com and www.windowsforms.com. He’s an active columnist for the asp alliance and Co-Authored in the ASP.NET Cook Book and currently working on a Smart Client book. His experience in .NET spans back to the early days of the first beta and he has a passion to spread the word to as many welcoming and un-welcoming ears that he can. Specializes in VB.NET and windows applications (rich client/smart client), also very knowledgeable of VS 2005 (been in beta since July 2003, after being invited to Microsoft). He’s very handy with MS SQL server 2000 and MSDE.