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 70799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:47:15+00:00 2026-05-10T19:47:15+00:00

In ASP.NET MVC, I’m trying to create a link that includes an anchor tag

  • 0

In ASP.NET MVC, I’m trying to create a link that includes an anchor tag (that is, directing the user to a page, and a specific section of the page).

The URL I am trying to create should look like the following:

<a href='/category/subcategory/1#section12'>Title for a section on the page</a> 

My routing is set up with the standard:

routes.MapRoute('Default', '{controller}/{action}/{categoryid}');  

The action link syntax that I am using is:

<%foreach (Category parent in ViewData.Model) { %> <h3><%=parent.Name %></h3> <ul> <%foreach (Category child in parent.SubCategories) { %>     <li><%=Html.ActionLink<CategoryController>(x => x.Subcategory(parent.ID), child.Name) %></li> <%} %> </ul> <%} %> 

My controller method is as follows:

public ActionResult Subcategory(int categoryID) {    //return itemList     return View(itemList); } 

The above correctly returns a URL as follows:

<a href='/category/subcategory/1'>Title for a section on the page</a> 

I can’t figure out how to add the #section12 part. The ‘section’ word is just the convention I am using to break up the page sections, and the 12 is the ID of the subcategory, i.e., child.ID.

How can I 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. 2026-05-10T19:47:16+00:00Added an answer on May 10, 2026 at 7:47 pm

    I would probably build the link manually, like this:

    <a href='<%=Url.Action('Subcategory', 'Category', new { categoryID = parent.ID }) %>#section12'>link text</a> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ASP.NET MVC web app that exposes friendly URLs: http://somesite.com/friendlyurl ...which are rewritten (not redirected)
ASP.NET MVC helpers generates URLs with slash, I use <base /> tag for my
ASP.NET MVC 2 I'm trying to write a view whose generic parameter is dynamic
ASP.NET MVC Model Binding is still new to me and I'm trying to understand
ASP.NET MVC app, close to completion, then it was decided that it needed a
ASP.NET MVC 2 renders a link (i.e. <a> ) to delete records. It can
Context: asp.net MVC 3 app. Page1 is a mobile page using jquery mobile and
In ASP.NET (MVC and WebAPI), how is the User Identity object initialized with the
In ASP.NET MVC how can I generate a URL to a specific controller and
ASP.NET MVC noob here I was writing a quiz application where a user can

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.