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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:40:07+00:00 2026-05-23T15:40:07+00:00

I’m getting an exception when using html helpers in mvc3. I got the exception

  • 0

I’m getting an exception when using html helpers in mvc3. I got the exception originally when using LabelFor and TextAreaFor with a ‘virtual’ parameter of a class. When I removed the virtual keyword it worked fine.

I’ve now come to add a LabelFor and an RadioBoxForEnum (Custom helper) and these use an enum (which isn’t virtual) and I’m getting the exception again.

Not sure whether it makes any difference but I’ve put this into a Telerik Tab.

The exception is:

CS1593: Delegate 'System.Action' does not take 1 arguments

Here’s the code:

items.Add().Text("Categorisation").Content(@<text>
        <div class="TabContent">
            <div class="5050SplitLeft">
                @Html.LabelFor(o => o.ChangeProposalHeader.ChangeProposal.ProgrammeCategory, "Programme:")
                @Html.TextAreaFor(o => o.ChangeProposalHeader.ChangeProposal.ProgrammeCategory
                <br />
                @Html.LabelFor(o => o.ChangeProposalHeader.ChangeProposal.InterfaceCategory, "Interface:")
                @Html.TextAreaFor(o => o.ChangeProposalHeader.ChangeProposal.InterfaceCategory)
                <br />
                @Html.LabelFor(o => o.ChangeProposalHeader.ChangeProposal.TechnicalReadinessCategory, "Technical Readiness Level:")
                @Html.TextAreaFor(o => o.ChangeProposalHeader.ChangeProposal.TechnicalReadinessCategory)
                <br />
                @Html.LabelFor(o => o.ChangeProposalHeader.ChangeProposal.DesignChangeRequirementCategory, "Design Change Requirement Category:")
                @Html.TextAreaFor(o => o.ChangeProposalHeader.ChangeProposal.DesignChangeRequirementCategory)
                <br />
                @Html.LabelFor(o => o.ChangeProposalHeader.ChangeProposal.FitType, "Fit Type:")
                @Html.RadioButtonForEnum(o => o.ChangeProposalHeader.ChangeProposal.FitType)
            </div>
            <div class="5050SplitRight">
            </div>
        </div></text>);

Heres the code for the Helper (I got this from another thread on SO)

 public static class HtmlExtensions
{
    public static MvcHtmlString RadioButtonForEnum<TModel, TProperty>(
        this HtmlHelper<TModel> htmlHelper,
        Expression<Func<TModel, TProperty>> expression
    )
    {
        var metaData = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
        var names = Enum.GetNames(metaData.ModelType);
        var sb = new StringBuilder();
        foreach (var name in names)
        {
            var id = string.Format(
                "{0}_{1}_{2}",
                htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix,
                metaData.PropertyName,
                name
            );

            var radio = htmlHelper.RadioButtonFor(expression, name, new { id = id }).ToHtmlString();
            sb.AppendFormat(
                "<label for=\"{0}\">{1}</label> {2}",
                id,
                HttpUtility.HtmlEncode(name),
                radio
            );
        }
        return MvcHtmlString.Create(sb.ToString());
    }
}

Thanks in advance.

J

  • 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-23T15:40:08+00:00Added an answer on May 23, 2026 at 3:40 pm

    Ok So i think there must be a problem with the RadioBoxForEnum code, as I found a different way of doing this and created an editor template using the following code I found and this works with any issues.

    Enum_radioButtonList.cshtml

    @model Enum
    
    @{
     // Looks for a [Display(Name="Some Name")] or a [Display(Name="Some Name", ResourceType=typeof(ResourceFile)] Attribute on your enum
    Func<Enum, string> getDescription = en =>
    {
        Type type = en.GetType();
        System.Reflection.MemberInfo[] memInfo = type.GetMember(en.ToString());
    
        if (memInfo != null && memInfo.Length > 0)
        {
    
            object[] attrs = memInfo[0].GetCustomAttributes(typeof(System.ComponentModel.DataAnnotations.DisplayAttribute),
                                                            false);
    
            if (attrs != null && attrs.Length > 0)
                return ((System.ComponentModel.DataAnnotations.DisplayAttribute)attrs[0]).GetName();
        }
    
        return en.ToString();
    };
    var listItems = Enum.GetValues(Model.GetType()).OfType<Enum>().Select(e =>
    new SelectListItem()
    {
        Text = getDescription(e),
        Value = e.ToString(),
        Selected = e.Equals(Model)
    });
    string prefix = ViewData.TemplateInfo.HtmlFieldPrefix;
    int index = 0;
    ViewData.TemplateInfo.HtmlFieldPrefix = string.Empty;
    
    foreach (var li in listItems)
    {
        string fieldName = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}_{1}", prefix, index++);
        <div class="editor-radio">
        @Html.RadioButton(prefix, li.Value, li.Selected, new { @id = fieldName }) 
        @Html.Label(fieldName, li.Text)    
        </div>
    }
    ViewData.TemplateInfo.HtmlFieldPrefix = prefix;
    }
    

    And this gets called as follows:

    @Html.EditorFor(o => o.ChangeProposalHeader.ChangeProposal.FitType, "Enum_radioButtonList")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.