【发布时间】:2021-09-20 09:41:34
【问题描述】:
删除某些事件后如何更新表格?该操作是从数据库中删除事件,但是,该行在那里。使用 DeleteThis 函数后如何删除行。
<div id="profile-dashboard-content-events">
<table>
<thead>
<tr>
<td>ID</td>
<td>Title</td>
<td>Delete</td>
</tr>
</thead>
<tbody>
@foreach (var theEvent in Model.EventsList)
{
<tr>
<td>@theEvent.Id</td>
<td>@theEvent.ShortTitle</td>
<td>
<a onclick="DeleteThis(@theEvent.Id)"><i class="fas fa-trash-alt iicon cursor-pointer"></i></a>
</td>
</tr>
}
</tbody>
</table>
<small style="color:#e0e0e0;">*Clear the last @_config["NumberOfEvents"], will delete the oldest @_config["NumberOfEvents"] events </small>
<br />
<small style="color:#e0e0e0;">*Delete past events, will delete all expired events </small>
</div>
<script>
function DeleteThis(theEventId) {
var baseUrl = "https://localhost:44380/Event/Delete";
var requestUrl = baseUrl + "?eventId=" + theEventId;
var data = {
eventId: theEventId
};
axios.delete(requestUrl, data)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
})
}
</script>
【问题讨论】:
标签: javascript asp.net asp.net-mvc asp.net-core