I'm new to MVC and i've been doing Shannon's tutorial http://shazwazza.com/post/Umbraco-v5-Surface-Controller-Forms.aspx. The form works well and validates etc however, I'd like to use some custom attributes / type for my inputs to take advantage of the new HTML5 semantics.
something like: @Html.EditorFor(x => someModel.Email, new {@type="number", @class = "testModel", @maxlength = "250", @aria_label="this is a test",@role="email"})
When i try to add properties I get the error below. Do I need to add a custom helper or something like that? Or can someone recommend another approach?
Thanks in advance.
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper<Umbraco.Cms.Web.Model.Content>' does not contain a definition for 'EditorFor' and the best extension method overload 'System.Web.Mvc.Html.EditorExtensions.EditorFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>, string, object)' has some invalid arguments
Source Error:
Line 10: <fieldset> Line 11: Line 12: @Html.EditorFor(x => someModel,new {@type="number"}, "MyTestForm") Line 13: <input type="submit" value="Submit" /> Line 14:
Surface form with HTML5 semantic elements
Hi There,
I'm new to MVC and i've been doing Shannon's tutorial http://shazwazza.com/post/Umbraco-v5-Surface-Controller-Forms.aspx. The form works well and validates etc however, I'd like to use some custom attributes / type for my inputs to take advantage of the new HTML5 semantics.
something like: @Html.EditorFor(x => someModel.Email, new {@type="number", @class = "testModel", @maxlength = "250", @aria_label="this is a test",@role="email"})
When i try to add properties I get the error below. Do I need to add a custom helper or something like that? Or can someone recommend another approach?
Thanks in advance.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper<Umbraco.Cms.Web.Model.Content>' does not contain a definition for 'EditorFor' and the best extension method overload 'System.Web.Mvc.Html.EditorExtensions.EditorFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>, string, object)' has some invalid arguments
Source Error:
Line 10: <fieldset>
Line 11:
Line 12: @Html.EditorFor(x => someModel,new {@type="number"}, "MyTestForm")
Line 13: <input type="submit" value="Submit" />
Line 14:
Source File: c:\inetpub\wwwroot\seankerr\Views\Umbraco\Partial\connectPartial.cshtml Line: 12
Without reading too much into this just yet, isn't it just that your arguments are in the wrong order to align with the parameters of 'EditorFor'?
Hi There,
I managed to solve it like this:
@Html.LabelFor(model => someModel.Email): @Html.TextBoxFor(x => someModel.Email, new {type="email", @class = "testModel", @maxlength = "250", @aria_label="this is a test",@role="email"})
Thanks for the suggestion anyway.
Sean
is working on a reply...