button is the icon link in the table:
- <tbody>
- @foreach (var item in Model)
- {
- <tr>
- <td class="edit1" scope="row">@Html.DisplayFor(model => item.Empid)</td>
- <td class="edit">@Html.DisplayFor(model => item.Empname)</td>
- <td class="edit">@Html.DisplayFor(model => item.Designation)</td>
- @*<td>
- <img src="@Url.Content(@item.Empimage)" alt />
- </td>*@
- <td class="edit">
- @{
- var base64 = Convert.ToBase64String(item.ImageData);
- var imagesrc = string.Format("data:image/jpeg;base64,{0}", base64);
- <img src='@imagesrc' style="max-width:100px;max-height:100px;" />
- }
- </td>
- <td class="edit">@Html.DisplayFor(model => item.Salary)</td>
- <td class="edit">@Html.DisplayFor(model => item.Email)</td>
- <td class="edit">@Html.DisplayFor(model => item.Department)</td>
- <td>
- <a href="#" data-id="@item.Empid" id="btnDelete" class="Delete" role="button" >
- <span class="glyphicon glyphicon-trash"></span>
- </a></td>
- </tr>
- }
- </tbody>
using normal button click:
- $(document).ready(function () {
- var empid = $('.Delete').attr('data-id');
- $("#EmpTable").on('click','.Delete',(function () {
- debugger;
- var url = '@Url.Action("DeleteEmployee", "Employee", new { id = empid })';
- var newurl = url + "empid" + empid;
- window.location.href = newurl;
- }));
or via ajax call:
- $(document).on('click', '#btnDelete', function () {
- var empID = $(this).attr('data-id');
- debugger;
- $.ajax(
- {
- type:'GET',
- url: '<%=Url.Action("DeleteEmployee","Employee")%>',
- data: "{ EmployeeID:'" + empID + "'}",
- success: function (data) {
- alert('deletion sucess');
- }
- });
both the things are not hitting tell me where i am wrong. Pls