One common requirement is to have multiple operations on a single record in a table and plan to manipulate the database in an AJAX asynchronous manner.
Main view
<td>
<div class= "Btn-group btn-group-sm" >
<a href= "@Url. Action (" Detailsadmin "," Applicationproject ", new {id = Item.) Applicationprojectid}) "class=" btn btn-primary "role=" button "> View project Contents </a>
<button type= "button" class= "btn btn-primary dropdown-toggle" data-toggle= "dropdown" >
<span class= "Caret" ></span>
<span class= "Sr-only" > Toggle drop-down menu </span>
</button>
<ul class= "Dropdown-menu" role= "Menu" >
<li> <a href= "@Url. Action (" Editadmin "," Applicationproject ", new {id = Item). Applicationprojectid}) "> Edit </a></li>
<li> <a href= "Javascript:deleteapplicationproject (' @item. Applicationprojectid ') > Delete </a></li>
<li> <a href= "Javascript:updateapplicationproject (' @item. Applicationprojectid ', ' Submitsingle ') "> Submit </a></li>
<li> <a href= "Javascript:updateapplicationproject (' @item. Applicationprojectid ', ' Submitnotsingle ') "> Cancel Submit </a></li>
<li> <a href= "Javascript:updateapplicationproject (' @item. Applicationprojectid ', ' Checkpasssingle ') "> First trial through </a></li>
<li> <a href= "Javascript:updateapplicationproject (' @item. Applicationprojectid ', ' Checknotpasssingle ') "> first trial not through </a></li>
</ul>
</div>
</td>
@* creates a hidden form that responds to a number of different actions and commits to different controllers *@
<form id= "Applicationprojectform" method= "POST" ><input type= "hidden" name= "id" id= "applicationprojectid"/ ></form>
2. Script files
<script type= "Text/javascript" > @* defining a cshtml file is more useful than defining a single JS file. Actually in JS inside can also use URL, HTML helper method. *@
//_reviewprojectid = $ ("Reviewprojectid"). Val ();
function Updateapplicationproject (ID, Action,reviewprojectid) {
$ ("#applicationProjectId"). Val (id);
var Choice = Confirm ("Are you sure you want to proceed?" ");
if (choice = = True)
{
Switch (action) {
case ' Submitsingle ':
$ ("#applicationProjectForm"). attr (' Acti On ', ' @Url. Action ("Makeasubmit"). Submit ();
break;
Case ' Submitnotsingle ':
$ ("#applicationProjectForm"). attr (' action ', ' @Url. Action ("Makeanotsubmit"). Submit ();
break;
Case ' Checkpasssingle ':
$ ("#applicationProjectForm"). attr (' action ', ' @Url. Action ("Makeapasscheck"). Submit ();
break;
Case ' Checknotpasssingle ':
$ ("#applicationProjectForm"). attr (' action ', ' @Url. Action ("Makeanotpasscheck") ' ). submit ();
break;
Default:
Console.debug (' Unknown action ' + action);//For browser debugging, pressing the F12 key displays the information in the Browser console window.
}
}
}
Multiple buttons in the table do not require the implementation of the jump page