Self Closing Tag

Oct 1, 2010 at 5:06 PM

The helper generates non-self closing tag like

 <%= Html.Html5TextBoxFor(m => m.UserName,InputTypes.InputType.Text) %>

<input id="UserName" name="UserName" placeholder="User Name" type="Text" value=""></input>

which does not pass W3C validation.

So I modified InputTypes.cs Html5TextBox method  to return

return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));  

and InputHelper method

  if (inputType == InputType.Text)
            {
                return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
            }
            return builder.ToHtmlString();

 


Coordinator
Feb 24, 2011 at 8:55 AM

Hi Haria

I will get this addition in as soon as possible. Thanks for the advice!

Dean

Aug 5, 2012 at 8:28 PM

Hi Dean,

Is there any chance of getting Haria's change into the nuget build soon? Thanks!

Derek.

Coordinator
Aug 6, 2012 at 10:11 AM

Hi Derek

The fix has been added and the lastest package is available on Nuget.

https://nuget.org/packages/MVCHtml5Toolkit/1.4

Enjoy!

Dean

Aug 6, 2012 at 2:07 PM

That was quick - thanks Dean.

Derek.