Как настроить представление создания шаблона asp.net MVC? - PullRequest
0 голосов
/ 21 марта 2019

Я создал вид создания шаблона следующим образом -

https://i.stack.imgur.com/sMnjC.png

И он автоматически создал страницу, подобную этой -

https://i.stack.imgur.com/lGeeZ.png

Как увеличить ширину ввода текста и формы?

Мой сгенерированный register.cshtml приведен ниже -

@model LoginPart.Models.Person

@{
ViewBag.Title = "Register";
}

<h2>Register</h2>


@using (Html.BeginForm()) 
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
    <h4>User1</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model => model.userName, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.userName, new { htmlAttributes = new { @class = "form-control col-md-10" } })
            @Html.ValidationMessageFor(model => model.userName, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.userEmail, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.userEmail, new { htmlAttributes = new { @class = "form-control col-md-10" } })
            @Html.ValidationMessageFor(model => model.userEmail, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.userPass, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.userPass, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.userPass, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.userPhone, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.userPhone, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.userPhone, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Create" class="btn btn-default" />
        </div>
    </div>
</div>
}



<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")

1 Ответ

1 голос
/ 21 марта 2019

Вы можете добавить собственный файл CSS для своей страницы.В макете cshtml

<head>
  @RenderSection("customcss", required: false)
</head>

В вашем cshtml для страницы

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section customcss
{
  <link href="~/Content/YourPage.css"  rel="stylesheet" type="text/css" />
}

In YourPage.css (мой пример)

input{ width: 300px;}
form{ width: 80%; }

Закомментируйте набор max-width вsite.css / input, select, textarea {max-width: 280px;} /

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...