Bootstrap 5 modal popup close from code behind wokring fine but after validation it fade page with below class
<div class="modal-backdrop fade show"></div>
<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Mobile # verification</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<asp:TextBox ID="TextboxOTP" runat="server" CssClass="form-control" ValidationGroup="OTP" />
<asp:RequiredFieldValidator ID="R7" runat="server" ErrorMessage="* Required " ForeColor="Red" ControlToValidate="TextboxOTP" Display="Dynamic" SetFocusOnError="true" ValidationGroup="OTP" Font-Size="Small"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<asp:Button ID="VerifyOTP" runat="server" Text="Verify" CssClass="btn btn-primary" ValidationGroup="OTP" />
</div>
</div>
</div>
</div>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" >
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.1/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.min.js"></script>
If TextboxOTP.Text = "123" Then
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.Page.[GetType](), "alert", "alert('Your order has been placed successfully');", True)
Else
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.Page.[GetType](), "alert", "alert('Wrong OTP');", True)
VerifyOTP.Attributes("Data-bs-dismiss") = "staticBackdrop"
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
sb.Append("<script type='text/javascript'>")
sb.Append("$('#staticBackdrop').modal('show');")
sb.Append("</script>")
ScriptManager.RegisterClientScriptBlock(Me, Me.[GetType](), "myModalScript", sb.ToString(), False)
End If