Skip to content
This repository has been archived by the owner on Apr 11, 2020. It is now read-only.

DataType.MultilineText does not generate textarea #147 #319

Open
sayedihashimi opened this issue Dec 2, 2015 · 4 comments
Open

DataType.MultilineText does not generate textarea #147 #319

sayedihashimi opened this issue Dec 2, 2015 · 4 comments

Comments

@sayedihashimi
Copy link
Contributor

sayedihashimi commented Dec 2, 2015

Originally posted by @madmunsterdaddy at dotnet/Scaffolding#147

Cross post from aspnet/Mvc#3651

In MVC5 you could do this:

public class ApplicationUser : IdentityUser
{
    [DataType(DataType.MultilineText)]
    public string Bio { get; set; }
}

That would generate a textarea tag to make it multi-line. Not working in MVC6 (rc1). The generated input control is not multi line.

From @dougbu

As mentioned in the original MVC issue: The generated view uses <input asp-for="Bio" class="form-control" />. Scaffolding should instead generate a <textarea/> element or use the more-general @Html.EditorFor() HTML helper.

The workaround is to use

@Html.EditorFor(m => m.Bio, additionalViewData: new { htmlAttributes = new { @class = "form-control" }})

or

    <textarea asp-for="Bio" class="form-control"></textarea>
@sayedihashimi
Copy link
Contributor Author

TFS: 169382
I've added this to our internal TFS, we will reply back here soon.

@VR-Architect
Copy link

FYI, the issue still exists in RC2.

@webtools-bot
Copy link

The GitHub Issue Tracker for the aspnet/Tooling repo is being deprecated in favor of Visual Studio's Report a Problem tool.

If this issue is still a problem with the RTW release of Visual Studio 2017, please report a new issue using the Report a Problem tool. While you can still use .NET Core and ASP.NET Preview tools with Visual Studio 2015, Visual Studio 2017 is now the officially supported tool for developing .NET Core and ASP.NET Core projects.

By using the Report a Problem tool (available in both VS 2017 and VS 2015), you can collect detailed information about the problem, and send it to Microsoft with just a few button clicks. See Visual Studio's Talk to Us page for more details.

Please use the discussion topic here for feedback and questions on the deprecation of this issue tracker. Thanks!

@ahedreville
Copy link

Hi see that the issue still persist on asp.net mvc core version 2.2

For a model such

public class Dto
{
    [DataType(DataType.MultilineText)]
    public string Name {get; set; }
}

The razor

            @Html.EditorFor(m => m.Name, additionalViewData: new { htmlAttributes = new { @class = "form-control" } })
            <input asp-for="Name" class="form-control" />

renders

<textarea class="form-control text-box multi-line" id="Name" name="Name"></textarea>
<input class="form-control" type="text" id="Name" name="Name" value="" />

Any update?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants