asp.net mvc - .NET MVC Ajax.ActionLink not returning partial view -


i have been researching , trying multiple failed attempts days partial view display within main view using ajax.actionlink. when using developer tools , viewing network tab, see request. when clicking on preview, can see correct data within partial view. no jquery errors.

view

@model ienumerable<ns.models.feeauth>  @using (html.beginform()) { <p>     <span class="glyphicon glyphicon-search"></span> find last name: @html.textbox("searchstring")     <input type="submit" value="search" /> </p> }  <div class="table-responsive">     <table class="table table-condensed" style="border-collapse:collapse;">         <tr>             <th>                 @html.labelfor(m => m.first().id)             </th>             <th>                  @html.actionlink("request id", "approvalindex", new { sortorder = viewbag.requestidsortparam })             </th>             <th>                 @html.label("emplid", "student emplid")             </th>          </tr>         @{int = 0;}         @foreach (var item in model)         {              <tr data-toggle="collapse" data-parent="#collapse1_@i" data-target="#collapse1_@i" class="accordion-toggle">                 <td>                      @ajax.actionlink(html.encode(item.id),            "selectedstrms",            "feeauth",            new { id = item.id, requestid = item.requestid }, new ajaxoptions {     httpmethod = "get",     updatetargetid = "selectedstrmlist" + i,     insertionmode = insertionmode.replace  })              </td>                  <td>                     @html.displayfor(modelitem => item.requestid)                 </td>                 <td>                     @html.displayfor(modelitem => item.emplid)                 </td>             </tr>             <tr>                 <td colspan="6" class="hiddenrow">                     <div class="accordion-body collapse" id="collapse1_@i">                         <div id="selectedstrmlist_@i">                          </div>                     </div>                 </td>              </tr>             i++;         }     </table> </div> 

partial view

<table>   <tr>      <td>          <ul>                   @foreach (var s in (list<string>)viewbag.semesterinfo)                  {                     <li style="padding-bottom:20px;">@s</li>                  }           </ul>       </td>  </tr>                </table>     

jquery in _layout.cshtml

<script src="~/scripts/jquery-2.1.3.js" type="text/javascript"></script> <script src="~/scripts/jquery-migrate-1.2.1.min.js" type="text/javascript"></script> <script src="~/scripts/jquery.validate.js" type="text/javascript"></script> <script src="~/scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script> <script src="~/scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script> 

controller

 [httpget]     public partialviewresult selectedstrms(int id, int requestid)     {          feeauthwithcommentsviewmodel feeauth = new feeauthwithcommentsviewmodel();         feeauth.feeauth = db.feeauths.find(id);          int feeauthid = id;         list<string> getstrm = new list<string>();          getstrm = db.vw_getstrms.where(v => v.feeauthid == feeauthid).select(v => v.descr).tolist();          if (getstrm.count > 0)         {             viewbag.semesterinfo = getstrm.tolist();         }         else         {              viewbag.semesterinfo = new list<string> { "no strm selected" };         }          return partialview("_selectedstrms");     }  

your update target is:

updatetargetid = "selectedstrmlist" + i, 

but div id is:

<div id="selectedstrmlist_@i"> 

in other words, you're either missing _ in update target string or need remove _ in div id.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -