Simple tab using CSS + sitemap + usercontrol + masterpage

Source: Internet
Author: User
When we perform website background management, we often need to use the tab-based navigation menu. This is true for the blog garden and blogengine. Some time ago, when we studied and modified blogengine, we saw that its tab implementation was so easy, A good idea, but one thing depressing me, his tab title is to take the file name, while the Chinese file name is to write Program Naturally, ASP comes to mind. net2.0 features web. sitemap: How does our data source not come from it? So we simply write it down. In fact, we only need a style file, a sitemap, a general usercontrol, and a master page.

 

Below is the core code)

Protected   Void Page_load ( Object Sender, eventargs E)
{
If ( ! Page. iscallback)
{
Bindmenu ();
}
}

///   <Summary>
/// Binds the menu.
///   </Summary>
Private   Void Bindmenu ()
{
Sitemapnodecollection smnc = Sitemap. currentnode. parentnode. childnodes;

Foreach(Sitemapnode SMNInSmnc)
{
Additem (SMN. Title, SMN. url );
}
}

///   <Summary>
/// Adds the item.
///   </Summary>
///   <Param name = "text"> The text. </Param>
///   <Param name = "url"> The URL. </Param>
Public   Void Additem ( String Text, String URL)
{
Htmlanchor =   New Htmlanchor ();
A. innerhtml =   " <Span> "   + Text +   " </Span> " ;
A. href = URL;

If (request. rawurl. endswith (URL, stringcomparison. ordinalignorecase)
. attributes [ " class " ] = " current " ;

Htmlgenericcontrol Li= NewHtmlgenericcontrol ("Li");
Li. Controls. Add ();
Ulmenu. Controls. Add (LI );
}

Running effect:

Download source code: Web projecttab.zip
Web site tab.rar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.