Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Controller:
C#
[HttpPost]
       public ActionResult DeleteStudent(int id)
       {
           Student s = db.Students.Include("Cla").Include("Section").Where(e => e.Id ==
                                   id).SingleOrDefault();
           db.Students.Remove(s);
           db.SaveChanges();
           return RedirectToAction("AllStudent", "Admin");
       }


My View:
HTML
@model PagedList.IPagedList<TakGayeYArHumB.Models.Student>
@using PagedList.Mvc;
 <table class="table table-bordered">
                        <tr>
                            <th>Options</th>
                        </tr>
                        @foreach (var item in Model)
                        {
                           <tr> 
                               <td>
                                  <div class="btn-group">
                                         <button type="button" class="btn btn-                     
                                      primary dropdown-toggle" data-toggle="dropdown">
                                           Action <span class="caret"></span>
                                         </button>
                                             <ul class="dropdown-menu" role="menu">
                                                                    <li>@Html.ActionLink("Edit", "UpdateStudent", new { id = item.Id })</li>
                                                                    <li>@Html.ActionLink("Delete", "DeleteStudent", new { @id = "form-message-delete" })</li>

                                                                 </ul>
                                                     
                                                             </div>
                                 
                                                        </td>
                                                    </tr>
                                                 }
                                        </table>





JavaScript
function messageDelete(index) {
    bootbox.dialog({
        message: "Are you sure you want to delete the message ?",
        title: "Delete Message Confirmation",
        buttons: {
            success: {
                label: "Continue",
                className: "btn-success",
                callback: function deletemember() {
                    $('.messageId').val(index);
                    $('#form-message-delete').submit();
                },
                danger: {
                    label: "Cancel",
                    className: "btn-danger",
                    callback: function () {
                        bootbox.hideAll();
                    }
                }
            }
        }
    });

};


What I have tried:

I'm trying to show a pop up When i click on a Delete Link. But it is not working. Can anyone solve this problem.Although it delete data correctly but not showing pop up.
Posted
Updated 6-Aug-16 0:46am
v2
Comments
Karthik_Mahalingam 6-Aug-16 9:29am    
are you using jquery popup ?
Muhammad Shan 7-Aug-16 4:33am    
yes! I'M using jquery pop up box.
Karthik_Mahalingam 7-Aug-16 9:19am    
use attribute to the actionlink to call the messageDelete function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900