I have this code, working perfectly just the way I want it
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="container">
<form class="well form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.ID_Reserva)
<div class="form-group">
@Html.LabelFor(model => model.ID_Cliente, "ID_Cliente", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("ID_Cliente", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.ID_Cliente, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DataEntrada, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DataEntrada, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DataEntrada, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DataSaida, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DataSaida, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DataSaida, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.TipoQuarto, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TipoQuarto, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TipoQuarto, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NumeroQuarto, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NumeroQuarto, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NumeroQuarto, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NumeroNoites, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NumeroNoites, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NumeroNoites, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Preço, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Preço, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Preço, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Observaçoes, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Observaçoes, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Observaçoes, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Salvar" class="btn btn-default" />
</div>
</div>
</form>
</div>
}
However, when I try to change this code up to this code, in order to change the format (aesthetic motif) gives me the following error!
Code
<div class="container">
<form class="well form-horizontal" action=" " method="post" id="contact_form">
<div class="form-group">
<label class="col-md-4 control-label">Nome Cliente</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input name="Nome Cliente" class="form-control" value="@Model.Cliente.Nome">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Data Entrada</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span>
<input name="Data Entrada" class="form-control" value="@Model.DataEntrada">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Data Saída</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span>
<input name="Data Saída" class="form-control" value="@Model.DataSaida">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Tipo Quarto</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-hotel"></i></span>
<input name="Tipo Quarto" class="form-control" value="@Model.TipoQuarto">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">NºQuarto</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-hotel"></i></span>
<input name="NºQuarto" class="form-control" value="@Model.NumeroQuarto">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">NºNoites</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-hotel"></i></span>
<input name="NºNoites" class="form-control" value="@Model.NumeroNoites">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Preço</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-euro"></i></span>
<input name="Preço" class="form-control" value="@Model.Preço">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Observações</label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
<textarea class="form-control" name="Observações" value="@Model.Observaçoes"></textarea>
</div>
</div>
</div>
</form>
</div>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4">
<button type="submit" class="btn btn-success">Editar<span class="glyphicon glyphicon-edit"></span></button>
@Html.ActionLink("Ir para a listagem de Reservas", "Index")
</div>
</div>
}
When running this give me this error
Entity
namespace WebApplication.Models.BaseDados
{
using System;
using System.Collections.Generic;
public partial class Reserva
{
public int ID_Reserva { get; set; }
public int ID_Cliente { get; set; }
public System.DateTime DataEntrada { get; set; }
public Nullable<System.DateTime> DataSaida { get; set; }
public string TipoQuarto { get; set; }
public int NumeroQuarto { get; set; }
public Nullable<int> NumeroNoites { get; set; }
public Nullable<decimal> Preço { get; set; }
public string Observaçoes { get; set; }
public virtual Cliente Cliente { get; set; }
}
}