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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:34:24+00:00 2026-05-24T01:34:24+00:00

I have a simple question. I have the following html code <a href=# class=purchase>

  • 0

I have a simple question.

I have the following html code

<a href="#" class="purchase">
<span>Purchase</span><em>@string.Format("{0:C0}", Model.thisItem.ItemSalePrice)</em>
</a>

But I want to use a Ajax.Actionlink to make it as a ajax post.

I have the following updated code

@Ajax.ActionLink("Purchase", "AddToCart", "Browse", new { ItemID = Model.thisItem.ItemID }, new AjaxOptions { UpdateTargetId = "content" }, new { @class = "purchase" })

The question is how I can put the tag into the actionlink?

Thank you everyone.

UPDATES

I also got an answer from ASP.NET’s forum, and it is even easier.
http://forums.asp.net/p/1702210/4518688.aspx/1?p=True&t=634468566867949718

  • 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-24T01:34:25+00:00Added an answer on May 24, 2026 at 1:34 am

    Just specify it in the action link text parameter:

    @Ajax.ActionLink(String.Format("{0} {1}", "Purchase", String.Format("{0:C0}", Model.thisItem.ItemSalePrice)), "AddToCart", "Browse", new { ItemID = Model.thisItem.ItemID }, new AjaxOptions { UpdateTargetId = "content" }, new { @class = "purchase" })
    

    EDIT 1:
    Other overloads are not shown, but this should be enough to get you started.
    If you need more details, you can take a look at the MVC3 source and see how they setup their helpers.

        public static MvcHtmlString CustomActionLink(this HtmlHelper htmlHelper, string linkText, float salePrice, string actionName, string controllerName, object routeValues, object htmlAttributes)
        {
            return CustomActionLink(htmlHelper, linkText, salePrice, actionName, controllerName, new RouteValueDictionary(routeValues), HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
        }
    
        public static MvcHtmlString CustomActionLink(this HtmlHelper htmlHelper, string linkText, float salePrice, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes)
        {
            var url = new UrlHelper(htmlHelper.ViewContext.RequestContext);
    
            // Build the <span> tag
            var spanBuilder = new TagBuilder("span");
            spanBuilder.SetInnerText(linkText);
            string spanHtml = spanBuilder.ToString(TagRenderMode.Normal);
    
            // Build the <em> tag
            var emBuilder = new TagBuilder("em");
            emBuilder.SetInnerText(String.Format("{0:C0}", salePrice));
            string emHtml = emBuilder.ToString(TagRenderMode.Normal);
    
            // Build the <a> tag
            var anchorBuilder = new TagBuilder("a");
            anchorBuilder.MergeAttribute("href", url.Action(actionName, controllerName, routeValues));
            anchorBuilder.InnerHtml = spanHtml + emHtml;
            string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);
    
            return MvcHtmlString.Create(anchorHtml);
        }
    

    Note: HtmlHelper.AnonymousObjectToHtmlAttributes is under the System.Web.Mvc namespace.

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

Sidebar

Related Questions

Simple question. I have the following HTML: <a rel=nofollow id=claim-job-link data-method=post class=button green claim-job
I have the following simple code : HTML: <div> <img src='http://i51.tinypic.com/4kz4g5.jpg' /> </div> CSS:
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I have a simple DOM code like the following <div> <div> </div> </div> I
yeah :( simple question * blush * Lets imagine i have the following enumeration:-
So, simple question really. :) I had this following code with ASPX View Engine
I have simple question about MVC routing. How i can construct Html.ActionLink thhat generates
Very green question here. I built a simple blog following the instructions here http://guides.rubyonrails.org/getting_started.html
I have a simple javascript question in the HTML page. In my case, the
I have a simple question. Is there a way ( using reflections I suppose

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.