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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:03:32+00:00 2026-05-12T06:03:32+00:00

I been playing around with some custom html helpers and I now I am

  • 0

I been playing around with some custom html helpers and I now I am trying to make one that I can use for jquery AJAX UI Tabs.

So to do ajax tabs you need to have this format in your html code

<div id="example">
     <ul>
         <li><a href="ahah_1.html"><span>Content 1</span></a></li>
         <li><a href="ahah_2.html"><span>Content 2</span></a></li>
         <li><a href="ahah_3.html"><span>Content 3</span></a></li>
     </ul>
</div>

so I can’t use ActionLink because I don’t think I can add anyway the tag to the actionLink.

So I want to make my own html helper that has an actionLink with a span tag in it and possibly build it up later on to have an unordered listed tag with it.

So I am not sure how to use the ActionLink to my benefit. Like the ActionLink has 10 overloaded methods and I don’t want to recreate all 10 of them since that just seems pointless. So is there away I can reference it or something like that?

I am using the way that allows my custom html helpers to show up when you do “Html.” in intellisense.

for instance I would have:

public static string Button(this HtmlHelper helper, string id, string value)

So I am not sure how to make use of this HtmlHelper I am passing in.

I also don’t understand this part of the line of code “this HtmlHelper helper”.

What confuses me is the using the keyword “this” in the parameter. I am not sure what it is refering to and why you need it. I also don’t understand how by passing this parameter but not using it somehow allows your customer Html helpers to be accesed by “Html.”.

Thanks

  • 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-12T06:03:32+00:00Added an answer on May 12, 2026 at 6:03 am

    Marc’s answer is excellent. Just adding some code:

    1) Create static class with your helper:

    public static class MyHtmlHelpers
    {
        public static string MySpecialActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues)
        {
            var innerTagBuilder = new TagBuilder("span") {
                InnerHtml = (!String.IsNullOrEmpty(linkText)) ? HttpUtility.HtmlEncode(linkText) : String.Empty
            };
    
            TagBuilder tagBuilder = new TagBuilder("a") {
                InnerHtml = innerTagBuilder.ToString(TagRenderMode.Normal);
            };
    
            var urlHelper = new UrlHelper(html.ViewContext.RequestContext);
            var url = urlHelper.Action(actionName, routeValues);
            tagBuilder.MergeAttribute("href", url);
    
            return tagBuilder.ToString(TagRenderMode.Normal);
        }
    }
    

    2) Add namespace of MyHtmlHelpers class to web.config:

    <pages>
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Linq" />
        <add namespace="System.Collections.Generic" />
    
        <add namespace="MyHtmlHelpers_Namespace" />
      </namespaces>
    </pages>
    

    3) Enjoy 🙂 :

    <div id="example">
        <ul>
            <li><%= Html.MySpecialActionLink("Content 1", "action1", null) %></li>
            <li><%= Html.MySpecialActionLink("Content 2", "action2", new { param2 = "value2" }) %></li>
            <li><%= Html.MySpecialActionLink("Content 3", "action3", new { param3 = "value3" }) %></li>
        </ul>
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been playing around with NSURLConnection. Now I'm trying to grab some data
I've been playing around with this for some time now and am hoping that
I've been playing around with QtDesigner for some time now, but I can't find
Ive been playing around with delegates trying to learn and I ran into one
I've been playing around with Qt for a few hours now. I found that
I have been playing around with Scala parser combinators for some time now, and
I have been playing around with jQuery for a bit now, and am really
I have been playing around with Umbraco 5 for some days now. I have
I have been playing around with some debugging and wrote some C code that
I have been playing around with some Python now and start to get a

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.