Couldn't you do something in code-behind like adding the HTML dynamically using string interpolation to pass in the ID of the item:
<button class='btn btn-danger delete-button' data-id='{item.Id}' type='button'>Delete</button>
<button class='btn btn-primary modify-button' data-id='{item.Id}' type='button'>Modify</button>
...and then in JavaScript do:
document.querySelector('#yourTimelineContainer').addEventListener('click', function(e) {
if (e.target.classList.contains('delete-button')) {
var id = e.target.getAttribute('data-id');
__doPostBack('DeleteEntry', id);
} else if (e.target.classList.contains('modify-button')) {
var id = e.target.getAttribute('data-id');
__doPostBack('ModifyEntry', id);
}
});
Then in your code-behind file again, handle the custom postbacks:
protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument)
{
base.RaisePostBackEvent(sourceControl, eventArgument);
if (eventArgument.StartsWith("DeleteEntry"))
{
var id = eventArgument.Replace("DeleteEntry", "");
DeleteEntry(id); // Your method to delete the entry
}
else if (eventArgument.StartsWith("ModifyEntry"))
{
var id = eventArgument.Replace("ModifyEntry", "");
// Show modal or redirect to modify page with the id
ShowModifyModal(id); // Your method to show modify modal
}
}
Maybe this helps?