when i click on the Button first time it shows nothing it is only on the second time that the Button shows the value captured but still when i click on ok it still do not show.
please help
<asp:Button ID="Button1" runat="server" OnClick="OnConfirm" Text="Send Diagnosis And Treament" />
<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('Button1').click();
}
</script>
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim message1 As String = "Are you Sure You Want To Post Diagnosis and Treatment"
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "Confirm('" & message1 & "');", True)
End Sub
Public Sub OnConfirm(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim confirmValue As String = Request.Form("confirm_value")
If confirmValue = "Yes" Then
'ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You clicked YES!')", True)
Dim sqlConnection12 As New SqlConnection(conString)
Dim objCommand22 As SqlCommand = New SqlCommand()
Dim cmd2 As New SqlCommand
cmd2.CommandText = "Pushdiagnosis"
cmd2.CommandType = CommandType.StoredProcedure
cmd2.Connection = sqlConnection12
cmd2.Parameters.Add("@Names", SqlDbType.NVarChar, 150).Value = PatientName.Text
cmd2.Parameters.Add("@admno", SqlDbType.NVarChar, 12).Value = PatientNo.Text
cmd2.Parameters.Add("@dg", SqlDbType.NVarChar, 12).Value = Diagnosisdata.Text
cmd2.Parameters.Add("@tr", SqlDbType.NVarChar, 12).Value = Treatmentdata.Text
'cmd2.Parameters.Add("@g", SqlDbType.NVarChar, 12).Value = fage.Replace(",", String.Empty)
cmd2.Parameters.Add("@dates", SqlDbType.DateTime, 4).Value = Dates.Text
sqlConnection12.Open()
cmd2.ExecuteReader()
sqlConnection12.Close()
ScriptManager.RegisterStartupScript(Me, GetType(), "showalert", "alert('Record Inserted Successfully');", True)
BindGrid()
Exit Sub
Else
ClientScript.RegisterStartupScript(Me.GetType(), "alert", "alert('You clicked NO!')", True)
End If
End Sub