0

Hi everyone, I'm going to start with a new experience with dotnet core using the MVC pattern.

Which are the new helpers for checkbox, textarea and other?

In this moment the relative page is empty : https://learn.microsoft.com/en-us/aspnet/core/mvc/views/html-helpers

I've tried this :

<input asp-for="myField" class="form-control" type="checkbox" value="False"/> but doesn't work!

Thanks in advance.

<div class="form-group">
      <label asp-for="myField" class="col-md-2 control-label"></label>
      <div class="col-md-10">
          @*<input asp-for="myField" class="form-control" type="checkbox" value="False"/>*@
          <span asp-validation-for="myField" class="text-danger"></span>
      </div>
</div>
1
  • Please post whole html here. Commented Dec 22, 2016 at 13:34

3 Answers 3

1

First check if you got reference to Microsoft.AspNet.Mvc.TagHelpers package in your project.json

Secondly remember about @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers at the beginning of your view.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer!
I get this when trying to Install-Package : Package Microsoft.AspNet.Mvc.TagHelpers 6.0.0-rc1-final is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Microsoft.AspNet.Mvc.TagHelpers 6.0.0-rc1-final supports: - dotnet5.4 (.NETPlatform,Version=v5.4) - net451 (.NETFramework,Version=v4.5.1) it seems doesn't work with .net core
0

If you want use HTML Helpers you can still do the same like in .Net Framework but MS want to change a bit HTML Helpers to Tag Helpers. Tag Helpers are new feature with .Net Core

Comments

0

I've been got error in the browser, because the field which I set is Nullable.

I've did the migration, update the database and now work!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.