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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:49:06+00:00 2026-06-03T03:49:06+00:00

I am trying to create a custom html button on my page using this

  • 0

I am trying to create a custom html button on my page using this

public static class HtmlButtonExtension 
{
  public static MvcHtmlString Button(this HtmlHelper helper, string text,
                                     IDictionary<string, object> htmlAttributes)
  {
      var builder = new TagBuilder("button");
      builder.InnerHtml = text;
      builder.MergeAttributes(htmlAttributes);
      return MvcHtmlString.Create(builder.ToString());
  }
}

When I click this button I want to pass an recordID to my Action

Given below is what I added to my razor view

@Html.Button(“Delete”, new {name=”CustomButton”, recordID =”1″ })

But I could not get to display this button,and it’s throwing erros

'System.Web.Mvc.HtmlHelper<wmyWebRole.ViewModels.MyViewModel>' does not contain a definition for 'Button' and the best extension method overload 'JSONServiceRole.Utilities.HtmlButtonExtension.Button(System.Web.Mvc.HtmlHelper, string, System.Collections.Generic.IDictionary<string,object>)' has some invalid arguments

Can some one help me to identify the actual error

  • 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-03T03:49:07+00:00Added an answer on June 3, 2026 at 3:49 am

    You’re passing an anonymous object, not an IDictionary<string, object> for htmlAttributes.

    You can add an additional overload with object htmlAttributes. This is how they do it in the built-in ASP.NET MVC Html Helpers:

    public static class HtmlButtonExtension 
    {    
      public static MvcHtmlString Button(this HtmlHelper helper, string text,
                                         object htmlAttributes)
      {
          return Button(helper, text, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
      }
    
      public static MvcHtmlString Button(this HtmlHelper helper, string text,
                                         IDictionary<string, object> htmlAttributes)
      {
          var builder = new TagBuilder("button");
          builder.InnerHtml = text;
          builder.MergeAttributes(htmlAttributes);
          return MvcHtmlString.Create(builder.ToString());
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a custom HTML Helper to help simplify my masterpages menu,
I am trying to create a custom HTML Helper that encapsulates some presentation logic
I'm trying to create a custom HTML helper and I would like to know
I am trying to create a custom accordion for my page to that display
I'm trying to create a custom control - a button - which will have
I'm trying to create a custom button where the foreColor is always crimson and
I am trying to create custom bullet points and it is not working. This
I'm trying to create a custom accordion using jquery, have read through quite a
I've been trying to create a custom renderer based on this Yehuda Katz's blog
I'm tasked with trying creating a site which will create custom HTML templates. The

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.