Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6075797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:32:05+00:00 2026-05-23T10:32:05+00:00

Im using the MVC Contrib project to generate my menu system for an MVC

  • 0

Im using the MVC Contrib project to generate my menu system for an MVC site.

How does one generate attributes in your <a href tag based on your SiteMap. Ive managed to achieve this by specifying the attributesToIgnore="target" in my provider definition in my web.config and adding the attribute to my mvcSiteMapNode element in my sitemap file.

<mvcSiteMapNode title="Hello World"
                    controller="Home"
                    action="Index"
                    changeFrequency="Always"
                    updatePriority="Normal"
                    target="_blank">
</mvcSiteMapNode>

I then iterate through my SiteMap file pick of the attribute using

siteMapNode["target"]

and render it myself as <a href="#" target="_blank" > </a>. Is there a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:32:05+00:00Added an answer on May 23, 2026 at 10:32 am

    Have you tried creating a SiteMapNodeModel display template? That allows you to construct your anchor tag however you wish. I created one to specifically add a class to the anchor if the node was in the current path so that I could apply specific CSS.

    Here is the razor partial view I use:

    @model MvcSiteMapProvider.Web.Html.Models.SiteMapNodeModel
    @{   
        if (Model.IsCurrentNode && Model.SourceMetadata["HtmlHelper"].ToString() !="MvcSiteMapProvider.Web.Html.MenuHelper")
    {
            @Model.Title    
        }
        else if (Model.IsClickable)
        {
            <a href="@Model.Url" class="@(Model.IsInCurrentPath ? "current" : string.Empty)" target="@Model.TargetFrame" >@Model.Title</a>
        }
        else
        {
        @Model.Title
        }
    
    }
    

    The file, named “SiteMapNodeModel.cshtml” (razor) goes in Shared/DisplayTemplates. When asp.net Mvc rendors a SiteMapNodelModel it will automatically use this template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the mvc contrib grid and generate the pager like this: <%=
I'm using the Contrib Grid for ASP.NET MVC and I was wondering if there
I am using the s#arp framework and want to use the latest mvc contrib.
I have been following this nice walkthrough for creating a grid using MVC contrib.
If you are using ASP.NET MVC how are you doing grid display? Rolled your
i m using Mvc Contrib grid to represent the data, now i want to
I m using MVC Contrib grid in the application , i want to change
I'm using MVC 2 with MVC contrib and Rhino mocks. I am in need
I am using Djangos default authentication system (django.contrib.auth) and I would like to add
I have MVC3 controllers in external assemblies using MVC contrib's portable areas but I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.