Reputation: 1
(ASP.NET) How do i prevent duplicate records insertion in my database when user refreshs the page after post back. i know it can handle by redirecting the page. it and also handle through the check if same entry exists inside the stored procedure. but this wont full fill requirement sometime. i just want to know is there any other good practice instead redirecting the page. (I know it can also handle using AJAX, but i am not using AJAX)
Upvotes: 0
Views: 939
Reputation: 8451
You can use the Page.IsPostBack property
private void Page_Load()
{
if (!IsPostBack)
{
//logic
}
}
In the code example above, if the page is a postback then no code would be executed (the logic).
Upvotes: 0