Ramco Ramco

Ramco Ramco

  • 443
  • 3.4k
  • 526.8k

How to pass values on click of Edit/Delete

May 30 2021 11:32 AM
Hi
 
How to pass values of row on click of Edit/View anchor tag to Modal
  1. @model IEnumerable<MyApplication.Models.Location>  
  2. <!DOCTYPE html>  
  3. <html>  
  4. <head>  
  5. <meta name="viewport" content="width=device-width" />  
  6. </head>  
  7. <body>  
  8. <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal" onclick="clearTextBox();">Add New Location</button><br /><br />  
  9. <table class="table" id="tblLocation">  
  10. <thead>  
  11. <tr>  
  12. <th>  
  13. @Html.DisplayNameFor(model => model.Id)  
  14. </th>  
  15. <th>  
  16. @Html.DisplayNameFor(model => model.Description)  
  17. </th>  
  18. <th>  
  19. @Html.DisplayNameFor(model => model.IsActive)  
  20. </th>  
  21. <th></th>  
  22. @*<th></th>*@  
  23. </tr>  
  24. </thead>  
  25. <tbody>  
  26. @foreach (var item in Model)  
  27. {  
  28. <tr>  
  29. <td>  
  30. @Html.DisplayFor(modelItem => item.Id)  
  31. </td>  
  32. <td>  
  33. @Html.DisplayFor(modelItem => item.Description)  
  34. </td>  
  35. <td>  
  36. @Html.DisplayFor(modelItem => item.IsActive)  
  37. </td>  
  38. <td>  
  39. <a href="#myModal" data-id="@item.Id" class="btn btn-primary btn xs" data-title="View" data-toggle="modal"><span class="fa fa-eye "></span></a>  
  40. <a href="#myModal" data-id="@item.Id" class="btn btn-primary btn xs" data-title="Edit" data-toggle="modal"><span class="fa fa-pencil"></span></a>  
  41. <a href="#myModal" data-id="@item.Id" class="btn btn-primary btn xs" data-title="Delete" data-toggle="modal"><span class="fa fa-trash"></span></a>  
  42. </td>  
  43. </tr>  
  44. }  
  45. </tbody>  
  46. </table>  
  47. </body>  
  48. </html>  
  49. <script src="~/Scripts/Appjs/Location.js"></script>  
  50. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">  
  51. <div class="modal-dialog">  
  52. <div class="modal-content">  
  53. <div class="modal-header">  
  54. <h4 class="modal-title">Add New Location</h4>  
  55. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>  
  56. </div>  
  57. <div class="modal-body">  
  58. <div class="form-horizontal">  
  59. <div class="form-group">  
  60. <label class="control-label col-sm-3" for="Id">Location Id</label>  
  61. <div class="col-sm-2">  
  62. <input type="text" class="form-control" id="txtId" placeholder="Id">  
  63. </div>  
  64. </div>  
  65. <div class="form-group">  
  66. <label class="control-label col-sm-3" for="Description">Location Name</label>  
  67. <div class="col-sm-9">  
  68. <input type="text" class="form-control" id="txtDescription" placeholder="Description">  
  69. </div>  
  70. </div>  
  71. <div class="form-group">  
  72. <label class="control-label col-sm-3" for="IsActive">Active</label>  
  73. <div class="col-sm-2">  
  74. <input type="text" class="form-control" id="txtIsActive" placeholder="Active">  
  75. </div>  
  76. </div>  
  77. </div>  
  78. </div>  
  79. <div class="modal-footer">  
  80. @*<button type="button" class="btn btn-primary" id="btnAdd" onclick="return Add();"><span class="glyphicon glyphicon-ok"></span>Save</button>*@  
  81. <button type="button" class="btn btn-primary" id="btnAdd" onclick="return Add();">Save</button>  
  82. <button type="button" class="btn btn-primary" id="btnUpdate" style="display:none;" onclick="Update();">Update</button>  
  83. <button type="button" class="btn btn-warning" data-dismiss="modal">Cancel</button>  
  84. </div>  
  85. </div>  
  86. </div>  
  87. </div>  
Thanks

Answers (4)