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

  • Home
  • SEARCH
  • 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 9104993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:59:30+00:00 2026-06-17T01:59:30+00:00

I have currently created an extension method using System.Web; using System.Web.Mvc; namespace Mobi.QualityControl.Site.Infrastructure {

  • 0

I have currently created an extension method

using System.Web;
 using System.Web.Mvc;

  namespace Mobi.QualityControl.Site.Infrastructure
{
public static class HtmlHelpers
{
    public static HtmlString ActionImage(this HtmlHelper htmlHelper, string action, object routeValues, string imagePath, string alt)
    {
        var url = new UrlHelper(htmlHelper.ViewContext.RequestContext);

        // build the <img> tag
        var imgBuilder = new TagBuilder("img");
        imgBuilder.MergeAttribute("src", url.Content(imagePath));
        imgBuilder.MergeAttribute("alt", alt);
        string imgHtml = imgBuilder.ToString(TagRenderMode.SelfClosing);

        // build the <a> tag
        var anchorBuilder = new TagBuilder("a");
        anchorBuilder.MergeAttribute("href", url.Action(action, routeValues));
        anchorBuilder.InnerHtml = imgHtml; // include the <img> tag inside
        string anchorHtml = anchorBuilder.ToString(TagRenderMode.Normal);
        return new HtmlString(anchorHtml);
    }
}

}

I am then trying to use it in my page with the using statement in my web.config and it is picking the method up but it

@HtmlHelpers.ActionImage(“Account/Register”, “/images/home/gettingstarted.png”, “Edit”, “GettingStarted”)

It says it still requires 5 parameters not 4.

It is probably something very simple. Any help would be appreciated.

  • 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-06-17T01:59:32+00:00Added an answer on June 17, 2026 at 1:59 am

    No, you are not calling your helper correctly. It should be like this:

    @Html.ActionImage("Account/Register", "/images/home/gettingstarted.png", "Edit", "GettingStarted")
    

    Html helpers in ASP.NET MVC are nothing more than extension methods in C# which I invite you to familiarize yourself with before getting into ASP.NET MVC.

    Basically in C#, extension methods are invoked on an instance of the class they are extending. In your case that’s the HtmlHelper class. A Razor view has a property called Html which is of type HtmlHelper. So you invoke the extension method on it:

    @Html.SOME_EXTENSION_METHOD_THAT_IS_BROUGHT_INTO_SCOPE_BY_A_USING_DIRECTIVE(...)
    

    Of course extension methods are nothing more than static methods that you could also invoke like this (it is wrong, please never invoke an extension method like that – it’s not what and how extension methods were designed for):

    @HtmlHelpers.ActionImage(Html, "Account/Register", "/images/home/gettingstarted.png", "Edit", "GettingStarted")
    

    Notice how I am passing Html as first argument of the static method. But never use that.

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

Sidebar

Related Questions

I created the following extension method for a ViewPage: using System.Web.Mvc; namespace G3Site {
Currently I have created a ABCFactory class that has a single method creating ABC
I currently have a thread that I created using CreateRemoteThread(). Everything works great. Upon
I currently have a (non commercial) application created in MS Visual C# 4.5, using
I have an ASP.NET MVC 3 site using a custom route for specifying the
We currently have a tool on our website that is created by JavaScript. The
I have created an Eclipse plugin which creates a view in Eclipse. Currently it
I am currently trying to pass an array that I have created in Javascript
I am currently working on grails project. I have created eight different plugins. Each
Currently, I have a project with a Windows Service. I also created another Setup

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.