Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sean 141 posts 179 karma points
    Mar 26, 2012 @ 12:57
    Sean
    0

    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

     

     

  • Grant Thomas 291 posts 324 karma points
    Mar 26, 2012 @ 15:53
    Grant Thomas
    0

    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'?

    @Html.EditorFor(x => model, "MyTestForm", new { })
  • Sean 141 posts 179 karma points
    Apr 01, 2012 @ 02:49
    Sean
    0

    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

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies