jquery - Ajax.actionLink input values of the partial view does not get posted with the host view -


i have search answer more 2 days now, please can help.

i have "create" view reservations can made restaurant. on view have able either create new guest of select existing guest. view default comes can select existing guest, if guest not there can click on ajax.actionlink render partial view create new guest. after have either selected current guest or fill in fields new guest continue reservation. @ end click create.

my goal fields of partial view reservation fields(host view) gets posted "create" controller, problem model binder not bind input field of partial view, can't save new guest new reservation database @ once.i'm using asp.net mvc5

main "create" view

@using (html.beginform())  {     @html.antiforgerytoken()      <div class="form-horizontal">         <h4>bistroreservations_reservation</h4>         <hr />         @html.validationsummary(true, "", new { @class = "text-danger" })         <div class="form-group">             @html.labelfor(model => model.dateofarrival, htmlattributes: new { @class = "control-label col-md-2" })             <div class="col-md-10">                 @html.editorfor(model => model.dateofarrival, new { htmlattributes = new { @class = "form-control datecontrol" } })                 @html.validationmessagefor(model => model.dateofarrival, "", new { @class = "text-danger" })             </div>         </div>          ...      <div class="form-group">         @html.labelfor(model => model.bistroreservations_guestid, htmlattributes: new { @class = "control-label col-md-2" })         <div class="col-md-6">             @html.dropdownlist("bistroreservations_guestid", null, htmlattributes: new { @class = "form-control" })                  @html.validationmessagefor(model => model.bistroreservations_guestid, "", new { @class = "text-danger " })              @ajax.actionlink("create new guest", "newguest", new ajaxoptions()            {                httpmethod = "get",                updatetargetid = "newguest",                insertionmode = insertionmode.replacewith,                           })                       </div>     </div>                 <div id="newguest" class="form-group">         </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> } 

partial view

@using (html.beginform())      {           <div class="form-horizontal">                         <hr />                 @html.validationsummary(true, "", new { @class = "text-danger" })              <div class="form-group">                 @html.labelfor(model => model.firstname, htmlattributes: new { @class = "control-label col-md-2" })                 <div class="col-md-10">                     @html.editorfor(model => model.firstname, new { htmlattributes = new { @class = "form-control" } })                     @html.validationmessagefor(model => model.firstname, "", new { @class = "text-danger" })                 </div>             </div>              <div class="form-group">                 @html.labelfor(model => model.lastname, htmlattributes: new { @class = "control-label col-md-2" })                 <div class="col-md-10">                     @html.editorfor(model => model.lastname, new { htmlattributes = new { @class = "form-control" } })                     @html.validationmessagefor(model => model.lastname, "", new { @class = "text-danger" })                 </div>             </div>              <div class="form-group">                 @html.labelfor(model => model.mobilenumber, htmlattributes: new { @class = "control-label col-md-2" })                 <div class="col-md-10">                     @html.editorfor(model => model.mobilenumber, new { htmlattributes = new { @class = "form-control" } })                     @html.validationmessagefor(model => model.mobilenumber, "", new { @class = "text-danger" })                 </div>             </div>                  <div class="form-group">                 @html.labelfor(model => model.email, htmlattributes: new { @class = "control-label col-md-2" })                 <div class="col-md-10">                     @html.editorfor(model => model.email, new { htmlattributes = new { @class = "form-control" } })                     @html.validationmessagefor(model => model.email, "", new { @class = "text-danger" })                 </div>             </div>                     </div>     <hr />        }    

create action method

[httppost] [validateantiforgerytoken] [actionname("create")] public actionresult create_post(bistroreservations_reservation reservation, bistroreservations_guest guest) {     if (modelstate.isvalid)     {         db.bistroreservations_reservations.add(reservation);         db.savechanges();         return redirecttoaction("index");     }      viewbag.bistroreservations_guestid = new selectlist(db.bistroreservations_guests, "bistroreservations_guestid", "firstname");     viewbag.bistroreservations_shiftid = new selectlist(db.bistroreservations_shifts, "bistroreservations_shiftid", "shiftdescription");     viewbag.bistroreservations_statusid = new selectlist(db.bistroreservations_statuses, "bistroreservations_statusid", "statusdescription");     viewbag.bistroreservations_typeofseatingid = new selectlist(db.bistroreservations_typeofseatings, "bistroreservations_typeofseatingid", "typeofseating");     viewbag.arrivaltime = new selectlist(db.bistroreservations_times, "bistroreservations_timeid", "time");     viewbag.departuretime = new selectlist(db.bistroreservations_times, "bistroreservations_timeid", "time");     viewbag.tablenoid = new selectlist(db.bistroreservations_tablenumbers, "bistroreservations_tablenoid", "number");     viewbag.locationid = new selectlist(db.bistroreservations_locations, "bistroreservations_locationid", "description");      return view(); } 

model main view

public partial class bistroreservations_reservation {       public int bistroreservations_reservationid { get; set; }      [display(name="day of reservations")]     [required]     [datatype(datatype.date)]     public datetime dateofarrival { get; set; }      public int bistroreservations_shiftid { get; set; }     public bistroreservations_shift bistroreservations_shift { get; set; }      public int bistroreservations_guestid { get; set; }     public virtual bistroreservations_guest bistroreservations_guest { get; set; }      [required]     [display(name = "arrival time")]     public int bistroreservations_timeid { get; set; }     public virtual bistroreservations_time arrivaltime { get; set; }      [required]         [display(name="departure time")]             public virtual bistroreservations_time departuretime { get; set; }         [display(name="location")]     public int locationid { get; set; }     public virtual bistroreservations_location bistroreservations_location { get; set; }      [display(name="type of seating")]     public int bistroreservations_typeofseatingid { get; set; }     public virtual bistroreservations_typeofseating bistroreservations_typeofseating { get; set; }      [display(name="table number")]     public int tablenoid { get; set; }     public virtual bistroreservations_tableno bistroreservations_tableno { get; set; }      [display(name="status")]     public int bistroreservations_statusid { get; set; }     public virtual bistroreservations_status bistroreservations_status { get; set; }      public virtual bistroreservations_arrivalstatus bistroreservations_arrivalstatus { get; set; }      [display(name="comments")]     public string comment { get; set; }      public datetime dateadded { get; set; }      public string userid  { get; set; }     public virtual user user { get; set; }      public virtual list<bistroreservations_reservationfurniture> bistroreservations_reservationfurniture { get; set; } 

model partial view

public class bistroreservations_guest {     public int bistroreservations_guestid { get; set; }      [display(name = "mobile number")]             public string mobilenumber { get; set; }      [required]     [display(name="first name")]     public string firstname { get; set; }      [required]     [display(name = "last name")]     public string lastname { get; set; }      [required]     [display(name="e-mail address")]     [emailaddress]     public string email { get; set; }      public virtual list<bistroreservations_reservation> bistroreservations_reservation { get; set; } } 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -