Hi makumbi,
Please refer below sample.
HTML
<table>
<tr>
<td>Cash</td>
<td>
<asp:TextBox ID="txtCash" runat="server" OnTextChanged="Cash_TextChanged"></asp:TextBox>
</td>
</tr>
</table>
<asp:Button ID="btnConfirm" runat="server" OnClick="OnConfirm" Style="display: none;" />
<script type="text/javascript">
function Confirm(message) {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm(message)) {
confirm_value.value = "Yes";
}
else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
document.getElementById('btnConfirm').click();
}
</script>
Code
C#
public void Cash_TextChanged(object sender, EventArgs e)
{
string value = txtCash.Text;
string message1 = "You have enetered Less money by: " + value + "\\nIf this is a credit sale enter the account No of the Customer, Is it a credit Sale ?";
ClientScript.RegisterStartupScript(this.GetType(), "alert", "Confirm('" + message1 + "');", true);
}
public void OnConfirm(object sender, EventArgs e)
{
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked YES!')", true);
}
else
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('You clicked NO!')", true);
}
}
VB.Net
Public Sub Cash_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim value As String = txtCash.Text
Dim message1 As String = "You have enetered Less money by: " & value & "\nIf this is a credit sale enter the account No of the Customer, Is it a credit Sale ?"
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "Confirm('" & message1 & "');", True)
End Sub
Public Sub OnConfirm(ByVal sender As Object, ByVal e As EventArgs)
Dim confirmValue As String = Request.Form("confirm_value")
If confirmValue = "Yes" Then
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You clicked YES!')", True)
Else
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You clicked NO!')", True)
End If
End Sub
Screenshot