c# - ajax updatetargetid with mvc partial views not rendering properly -


i have view contains tab layout, each tab contains form submitting through ajax.beginform. if modelstate not valid return view cannot work out how render view properly. when submit 1 of forms renders whole page again within tab, don't want. thought using ajax updatetargetid render div needs replacing, said renders whole page within tab.

view

   @model trakman_portal_administration.models.vehlist    @using trakman_portal_administration.models    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />   @*<script src="@url.content("~/scripts/jquery.unobtrusive-ajax.min.js")"    type="text/javascript"></script>*@  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>  <script>  $(function () {      $("#tabs").tabs();  });  </script>  @{    viewbag.title = "edit";  }  <div class="editbanner">  <div class="editor-label">    @* @{     string custcode = viewbag.custcode;                 }*@     @* <h2>@html.label(custcode, custcode )</h2>*@     <h2>@html.label(model.column_8, model.column_8 )</h2>     </div>     </div>     <h3 style="font-size:20px">edit</h3>      <br />     @*  tab 1 vehicle data saved vehlist   *@    <div id="tabs"> <ul>     <li><a href="#tabs-1">vehicle</a></li>     <li><a href="#tabs-2">page 1</a></li>     <li><a href="#tabs-3">page 2</a></li> </ul>   <div id="tabs-1">   @using (ajax.beginform("edit",null, new ajaxoptions   {     onsuccess = "onsuccesseditvehicle",     onfailure = "onfailureeditvehicle",     httpmethod = "post",     updatetargetid = "tabs-1"   }, new {id="editvehicle"})) {   @html.validationsummary(true)  <fieldset>     <legend>vehlist</legend>          @html.editorformodel()  </fieldset>    <div style="position:relative;left:750px">             @html.actionlink("back list", "index", new {custcode= viewbag.custcode,    conname = viewbag.connectionname}) |        <input type="submit" value="save" /></div> }   @* tab 1 vehicle data saved vehicledata *@  </div> <div id="tabs-2">     @{          vehicledata vd =   ((trakman_portal_administration.controllers.vehiclecontroller)this.viewcontext.controller).editvdpartial(model.column_0);     }         @html.partial("editvdpartial", vd)     @*  <div style="position:relative;left:750px">             @html.actionlink("back list", "index", new {custcode= viewbag.custcode,   conname = viewbag.connectionname}) |        <input type="button" value="save" onclick="submitvehicledataform()" /></div>*@   </div>    @*  tab 3 vehicle data saved vehicle  *@ <div id="tabs-3">      @{           vehicle v =    ((trakman_portal_administration.controllers.vehiclecontroller)this.viewcontext.controller).editpartial(model.column_0);       }          @html.partial("editpartial", v)       <div style="position:relative;left:750px">             @html.actionlink("back list", "index", new {custcode= viewbag.custcode, conname = viewbag.connectionname}) |        <input type="submit" value="save" /></div>  </div>     </div>   <br /> 

controller

 public actionresult edit(vehlist vehlist)     {          tedb = new     trakman_entities(system.web.httpcontext.current.session["connection"].tostring());         if (modelstate.isvalid)         {             vehlist.column_8 =    system.web.httpcontext.current.session["staticcustcode"].tostring();             tedb.vehlists.attach(vehlist);             tedb.objectstatemanager.changeobjectstate(vehlist, system.data.entitystate.modified);             tedb.savechanges();             var cust = tedb.customers.first(c => c.code == vehlist.column_8);             //return redirecttoaction("index", new { custcode = cust.code, conname = system.web.httpcontext.current.session["connectionname"]});         }          viewbag.column_8 = new selectlist(tedb.customers, "code", "name", vehlist.column_8);         return view(vehlist);      } 


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -