To prevent duplicate numbers from being generated, I added a button that, when clicked by a user, displays a message indicating that the value is being saved to avoid duplicates. However, when attempting to handle this on the server side controller, I encountered a status 302 POST error under Inspect element->Network->Status 302 -> POST -> FILE (GenerateCodes).
@using (Html.BeginForm("GenerateCodes", "Codes", FormMethod.Post))
{
<div class="box-header">
<div class="row">
<div class="col-md-3 text-right">
<!--Disable button for about 3 second after click button-->
<button type="submit" id="ok" class="btn btn-primary btn-lg" onclick="return DisplayProgressMessage(this, 'Saving...');">Generate</button>
<script>
function DisplayProgressMessage(ctl, msg) {
$(ctl).prop("disabled", true);
$(ctl).text(msg);
return true;
}
</script>
</div>
</div>
</div>
}
My Codes.cs controller.
protected void DisplayProgressMessage(object sender, EventArgs e)
{
//Something
Response.Write("DD");
}