Note that there are some explanatory texts on larger screens.

plurals
  1. PO'System.Action' does not take 1 arguments HtmlHelper MVC3
    text
    copied!<p>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. </p> <p>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.</p> <p>Not sure whether it makes any difference but I've put this into a Telerik Tab.</p> <p>The exception is:</p> <pre><code>CS1593: Delegate 'System.Action' does not take 1 arguments </code></pre> <p>Here's the code:</p> <pre><code>items.Add().Text("Categorisation").Content(@&lt;text&gt; &lt;div class="TabContent"&gt; &lt;div class="5050SplitLeft"&gt; @Html.LabelFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.ProgrammeCategory, "Programme:") @Html.TextAreaFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.ProgrammeCategory &lt;br /&gt; @Html.LabelFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.InterfaceCategory, "Interface:") @Html.TextAreaFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.InterfaceCategory) &lt;br /&gt; @Html.LabelFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.TechnicalReadinessCategory, "Technical Readiness Level:") @Html.TextAreaFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.TechnicalReadinessCategory) &lt;br /&gt; @Html.LabelFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.DesignChangeRequirementCategory, "Design Change Requirement Category:") @Html.TextAreaFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.DesignChangeRequirementCategory) &lt;br /&gt; @Html.LabelFor(o =&gt; o.ChangeProposalHeader.ChangeProposal.FitType, "Fit Type:") @Html.RadioButtonForEnum(o =&gt; o.ChangeProposalHeader.ChangeProposal.FitType) &lt;/div&gt; &lt;div class="5050SplitRight"&gt; &lt;/div&gt; &lt;/div&gt;&lt;/text&gt;); </code></pre> <p>Heres the code for the Helper (I got this from another thread on SO)</p> <pre><code> public static class HtmlExtensions { public static MvcHtmlString RadioButtonForEnum&lt;TModel, TProperty&gt;( this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; 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( "&lt;label for=\"{0}\"&gt;{1}&lt;/label&gt; {2}", id, HttpUtility.HtmlEncode(name), radio ); } return MvcHtmlString.Create(sb.ToString()); } } </code></pre> <p>Thanks in advance.</p> <p>J</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload