button is the icon link in the table:
-
- @foreach (var item in Model)
- {
class="edit1" scope="row">@Html.DisplayFor(model => item.Empid) class="edit">@Html.DisplayFor(model => item.Empname) class="edit">@Html.DisplayFor(model => item.Designation) - @*
*@"@Url.Content(@item.Empimage)" alt />
class="edit"> - @{
- var base64 = Convert.ToBase64String(item.ImageData);
- var imagesrc = string.Format("data:image/jpeg;base64,{0}", base64);
'@imagesrc' style="max-width:100px;max-height:100px;" />
- }
class="edit">@Html.DisplayFor(model => item.Salary) class="edit">@Html.DisplayFor(model => item.Email) class="edit">@Html.DisplayFor(model => item.Department) - "#" data-id="@item.Empid" id="btnDelete" class="Delete" role="button" >
- class="glyphicon glyphicon-trash">
- }
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');
- }
- });
Kaushik DhameliyaPosted Apr 4, 2018, 3:54 AM
sangeetha kPosted Apr 4, 2018, 5:13 AM
Kaushik DhameliyaPosted Apr 4, 2018, 5:08 AM
sangeetha kPosted Apr 4, 2018, 4:59 AM
Kaushik DhameliyaPosted Apr 4, 2018, 4:58 AM
sangeetha kPosted Apr 4, 2018, 4:42 AM