Problem using an @Html.LabelFor and @Html.textBoxFor of a Registration Form in ASP.NET MVC

0

I'm new to ASP.NET MVC. I am trying to make a registration form, for that I am guided by the same example that provides visual mvc. But at the same time I'm showing a datatable to list a class, in this case "PERSONAL" My controller calls the PersonalView view, it receives the Personnel list and shows them as normal. But the problem is that I am trying to create a form at the same time in the main part, so that at the moment I register, I list them at the same time. It sends me an error in the @ Html.LabelFor (m = > m.Name) and the @ Html.TextBoxFor (m = > m.Name).

From what I understand it is that when you receive the list, it can not access the attributes, so it sends me the error, but I have no idea how to access the attributes themselves and insert the data.

Code:

@*@using Prueba2.Models

@model Personal*@

 
 
@model IEnumerable<Prueba2.Models.Personal>

@section Styles{
    @Styles.Render("~/Content/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css")
}

@section Personal{


    @using (Html.BeginForm("Register", "Personal", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
    {
        <div class="box box-default">
            <div class="box-header">
                <h3 class="box-title">Registro de Docentes</h3>
            </div>
            <div class="box-body">
                <div class="col-md-10 form-group">
                     @Html.LabelFor(Persona.)
                    @Html.LabelFor(m => m.Nombre, new { @class = "col-md-2 control-label" })
                    <div class="col-md-8">
                        @Html.TextBoxFor(m => m.Nombre, new { @class = "form-control" })
                    </div>
                </div>
                <div class="col-md-12 form-group">
                    @Html.LabelFor(m => m.ApellidoP, new { @class = "col-md-2 control-label" })
                    <div class="col-md-4">
                        @Html.TextBoxFor(m => m.ApellidoP, new { @class = "form-control" })
                    </div>

                    @Html.LabelFor(m => m.ApellidoM, new { @class = "col-md-2 control-label" })
                    <div class="col-md-4">
                        @Html.TextBoxFor(m => m.ApellidoM, new { @class = "form-control" })
                    </div>
                </div>
                <div class="col-md-12 form-group">
                    @Html.LabelFor(m => m.DNI, new { @class = "col-md-2 control-label" })
                    <div class="col-md-3">
                        @Html.TextBoxFor(m => m.DNI, new { @class = "form-control" })
                    </div>

                    @Html.LabelFor(m => m.Direccion, new { @class = "col-md-2 control-label" })
                    <div class="col-md-5">
                        @Html.TextBoxFor(m => m.Direccion, new { @class = "form-control" })
                    </div>
                </div>
                <div class="col-md-12 form-group">
                    @Html.LabelFor(m => m.Telefono, new { @class = "col-md-2 control-label" })
                    <div class="col-md-4">
                        @Html.TextBoxFor(m => m.Telefono, new { @class = "form-control" })
                    </div>

                    @Html.LabelFor(m => m.SeguroSocial, new { @class = "col-md-2 control-label" })
                    <div class="col-md-4">
                        @Html.TextBoxFor(m => m.SeguroSocial, new { @class = "form-control" })
                    </div>
                </div>
                <div class="col-md-6 form-group">
                    @Html.LabelFor(m => m.FechaIngreso, new { @class = "col-md-2 control-label" })
                    <div class="col-md-4">
                        @Html.TextBoxFor(m => m.FechaIngreso, new { @class = "form-control" })
                    </div>
                </div>
                <div class="col-md-6"></div>
                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" class="btn btn-default" value="Registrarse" />
                    </div>
                </div>
            </div>
        </div>
        //@model IEnumerable<Prueba2.Models.Personal>

        //PARA LISTAR A LOS DOCENTES
        <div class="box box-default">
            <div class="box-header">
                <h3 class="box-title">Lista de docentes</h3>
            </div>
            <div class="box-body">
                <table id="tableDocente" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>
                                @Html.DisplayNameFor(model => model.Nombre)
                            </th>

                            <th>
                                @Html.DisplayNameFor(model => model.DNI)
                            </th>
                            <th>
                                @Html.DisplayNameFor(model => model.Direccion)
                            </th>
                            <th>
                                @Html.DisplayNameFor(model => model.Telefono)
                            </th>
                            <th>
                                @Html.DisplayNameFor(model => model.SeguroSocial)
                            </th>
                            <th>
                                @Html.DisplayNameFor(model => model.FechaIngreso)
                            </th>
                            @*<th>
                                @Html.DisplayNameFor(model => model.FK_SeccionID)
                            </th>*@
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model)
                        {
                            <tr>
                                 
                                <td>

                                    @Html.DisplayFor(modelItem => item.Nombre)
                                </td>

                                <td>
                                    @Html.DisplayFor(modelItem => item.DNI)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Direccion)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.Telefono)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.SeguroSocial)
                                </td>
                                <td>
                                    @Html.DisplayFor(modelItem => item.FechaIngreso)
                                </td>
                                @*<td>
                                    @Html.DisplayFor(modelItem => item.FK_SeccionID)
                                </td>*@
                                <td>
                                    @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
                                    @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
                                    @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        </div>
    }


}
@section scripts{

    @Scripts.Render("~/Content/bower_components/datatables.net/js/jquery.dataTables.min.js")
    @Scripts.Render("~/Content/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js")
    @Scripts.Render("~/Content/bower_components/fastclick/lib/fastclick.js")
}

Error:

    
asked by Luis Fernando Zumaran 12.11.2018 в 00:20
source

0 answers