Skip to content
Loading
  
  •   
  •                             class="form-group row">  
  •                                 for="Name" class="col-sm-2 col-form-label">Name:  
  •                                 class="col-sm-3 ">  
  •                                     @Html.EditorFor(model => model.RegForm.FirstName, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Name" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.FirstName, "", new { @class = "text-danger" })  
  •   
  •                                   
  •   
  •                                 class="col-sm-3">  
  •                                     @Html.EditorFor(model => model.RegForm.LastName, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "LastName" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.LastName, "", new { @class = "text-danger" })  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 for="Position" class="col-sm-2 col-form-label">Position:  
  •                                 class="col-sm-3">  
  •                                     @Html.EditorFor(model => model.RegForm.Position, new { htmlAttributes = new { @class = "form-control" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.Position, "", new { @class = "text-danger" })  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 for="Company" class="col-sm-2 col-form-label">Company:  
  •                                 class="col-md-3">  
  •                                     @Html.EditorFor(model => model.RegForm.Company, new { htmlAttributes = new { @class = "form-control" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.Company, "", new { @class = "text-danger" })  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 for="Addresss" class="col-sm-2 col-form-label">Address*  
  •                                 class="col-sm-5">  
  •                                     @Html.EditorFor(model => model.RegForm.StreetAddress, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Street Address" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.StreetAddress, "", new { @class = "text-danger" })  
  •                                   
  •                               
  •                             class="form-group row">  
  •                                 for="Address" class="col-sm-2 col-form-label">  
  •                                 class="col-sm-5">  
  •                                     @Html.EditorFor(model => model.RegForm.StreetAddress, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Street Address Line 2" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.StreetAddress, "", new { @class = "text-danger" })  
  •                                   
  •                               
  •                             class="form-group row">  
  •                                 for="City" class="col-sm-2 col-form-label">  
  •                                 class="col-sm-3">  
  •                                     @Html.EditorFor(model => model.RegForm.City, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "City" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.City, "", new { @class = "text-danger" })  
  •                                   
  •                                 for="State/Province" class="col-form-label">  
  •                                 class="col-sm-3">  
  •                                     @Html.EditorFor(model => model.RegForm.StateProvince, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "State/Province" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.StateProvince, "", new { @class = "text-danger" })  
  •                                   
  •   
  •                               
  •                             class="form-group row">  
  •                                 for="ZipCode" class="col-sm-2 col-form-label">  
  •                                 class="col-sm-3">  
  •                                     @Html.EditorFor(model => model.RegForm.ZipCode, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "ZipCode" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.ZipCode, "", new { @class = "text-danger" })  
  •                                   
  •   
  •                                 class="col-sm-3">  
  •                                     @Html.DropDownListFor(m => m.ListCountries.Country, ViewBag.CountryList as SelectList)  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 for="Email" class="col-sm-2 col-form-label">Email:  
  •                                 class="col-sm-4">  
  •                                     @Html.EditorFor(model => model.RegForm.Email, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Email" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.Email, "", new { @class = "text-danger" })  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 for="Attendee" class="col-sm-2 col-form-label">Attendee Cell Number*  
  •                                 class="col-sm-3">  
  •                                     @Html.EditorFor(model => model.RegForm.CellNumber, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Cell Number" } })  
  •                                     @Html.ValidationMessageFor(model => model.RegForm.CellNumber)  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 for="Verify not a human" class="col-sm-2 col-form-label">Please verify you not a human*  
  •                                 class="col-sm-3">  
  •                                     @using (Html.BeginForm("FormSubmit", "GetCapatcha", FormMethod.Post))  
  •                                     {  
  •                                         class="g-recaptcha" data-sitekey="6LcLN6cZAAAAABbgHtWziQB9nsWNXqZcpBnLU6dd">  
  •   
  •                                           
  •                                     }  
  •                                   
  •                               
  •   
  •                             class="form-group row">  
  •                                 class="col-sm-2 col-form-label">Dietary requirements:  
  •                                 class="col-sm-3">  
  •                                     class="form-check">  
  •                                         @Html.CheckBoxFor(m => m.DietMain.None, new { @class = "form-check-input" })  
  •                                         class="form-check-label" for="@Html.IdFor(m => m.DietMain.None)">None  
  •                                       
  •                                     class="form-check">  
  •                                         @Html.CheckBoxFor(m => m.DietMain.Vegetarian, new { @class = "form-check-input" })  
  •                                         class="form-check-label" for="@Html.IdFor(m => m.DietMain.Vegetarian)">Vegetarian  
  •                                       
  •   
  •                                     class="form-check">  
  •                                         @Html.CheckBoxFor(m => m.DietMain.Vegan, new { @class = "form-check-input" })  
  •                                         class="form-check-label" for="@Html.IdFor(m=>m.DietMain.Vegan)">Vegan  
  •                                       
  •   
  •                                     class="form-check">  
  •                                         @Html.CheckBoxFor(m => m.DietMain.Halaal, new { @class = "form-check-input" })  
  •                                         class="form-check-label" for="@Html.IdFor(m=>m.DietMain.Halaal)">Halaal  
  •                                       
  •   
  •                                     class="form-check">  
  •                                         @Html.CheckBoxFor(m => m.DietMain.Other, new { @class = "form-check-input" })  
  •                                         class="form-check-label" for="@Html.IdFor(m=>m.DietMain.Other)">Other  
  •                                       
  •   
  •                                   
  •                               
  •   
  •                           
  •   
  •                         class="form-group">  
  •                             class="col-md-offset-2 col-md-10">  
  •                                 "submit" value="Submit" class="btn btn-primary" />  
  •   
  •                               
  •                           
  •   
  •                     }  
  •                     
      
  •                         @Html.ActionLink("Back to list", "SaveRegForm")  
  •                       
  •                   
  •  
    0
  • Jenith Thakkar
    0
    Hi Gcobani Mkontwana,
    At the top of your view page which model you're using 
    like 
    @using eNtsaRegistrationTraining.Models.RegViewAndRoleViewModel
    0
  • 0
    1. public ActionResult SaveRegForm()  
    2.   {  
    3.       ViewBag.Message = "Details saved successfull";  
    4.       return View(db.TrainingRegs.ToList());  
    5.   }  
    6.   
    7.   
    8.   //GET:TrainingRegForm/Submit.  
    9.  public ActionResult SubmitRegDetails()  
    10.   {  
    11.       // Initialization.  
    12.       this.ViewBag.CountryList = this.GetCountryList();  
    13.       this.ViewBag.SaveRegForm = this.SaveRegForm();  
    14.   
    15.       RegViewAndRoleViewModel model = new RegViewAndRoleViewModel();  
    16.   
    17.       return View(model);  
    1.   }



    2. // View.cshtml

    3. @using (Html.BeginForm("SaveRegForm", "Home", FormMethod.Post))
      {
      // Form properties 
      }  
    Hi Jenith
     
    This is what i have tried to do on the controller side to access the SaveRegForm() method be accessible for table definition. Its now complaining about the model being changed. Countrylist does not uses db schema rather its a file to access all list of countries. I have created migration and enable it to allow all changes if model is changed. Please advice mates, the logic i want to able to send all the properties from the form to my table within db.
     
     
    System.InvalidOperationException
    HResult=0x80131509
    Message=The model backing the 'eNtsaRegistration' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
    Source=
    StackTrace:
    0