Community discussion forum
A twist on Confirmation box
-
Hello,
I am sort of new with ASP.net so forgive me for this question. I have been trying to find a solution. I have been given an app to make changes on. It requires a confirmation box to pop up after a duplicate check has been made.
On the aspx page there is a submit button. When that is clicked it activates the onclick event in the codefile/codebehind.
In the onclick code it searches through the database for duplicate name and duplicate ID. If it is found a javascript confirmation button is added to the form object.
However when the confirmation box pops up I have no idea how to capture the event. Below is the code.
Protected Sub cmdInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim oSb As New System.Text.StringBuilder
Dim oFormObject As New System.Web.UI.Control
Dim oCmd As New OracleCommand
Dim oPersonId As Double
Dim oAcc As KeySortDropDownList.Thycotic.Web.UI.WebControls.KeySortDropDownList
'Dim oSalTextBox As TextBox
Dim oFirstTextBox As TextBox
Dim oLastTextBox As TextBox
Dim oEMail As TextBox
Dim oEmpID As TextBox
Dim oPhone As New WebDataInput.WebMaskEdit
Dim NameDuplicatePresent As Boolean
Dim EmployeeIDPresent As Boolean
Try
oAcc = Me.PersonFormView.FindControl("AccDropDownList")
'oSalTextBox = Me.PersonFormView.FindControl("SALUTATIONEdit")
oFirstTextBox = Me.PersonFormView.FindControl("FIRST_NAMEEdit")
oLastTextBox = Me.PersonFormView.FindControl("LAST_NAMEEdit")
oEMail = Me.PersonFormView.FindControl("EMAILEdit")
oPhone = Me.PersonFormView.FindControl("BUS_PHONEEdit")
oEmpID = Me.PersonFormView.FindControl("EMPLOYEE_IDEdit")
'filter changes
'
If oFirstTextBox.Text <> "" And oLastTextBox.Text <> "" And oAcc.SelectedValue <> "" And oEMail.Text <> "" And oPhone.Value <> "" Then
oPersonId = Main.GetNextPersonID
Me.PersonDataSource.InsertParameters("PERSON_ID").DefaultValue = oPersonId
Me.PersonDataSource.InsertParameters("USER_ID").DefaultValue = Request.Cookies("NDM").Values("UserID")
NameDuplicatePresent = NameDuplicates(oFirstTextBox.Text, oLastTextBox.Text, oPersonId)
EmployeeIDPresent = EmployeeIdDuplicate(oEmpID.Text)**********Area of QUESTION ************
If (NameDuplicatePresent) Then
oSb.Append("<script language=""javascript"" type=""text/javascript"">")
oSb.Append("confirm('First and last name already exist.Do you wish to proceed?')")
oSb.Append("</script>")ElseIf (EmployeeIDPresent) Then
oSb.Append("<script language=""javascript"" type=""text/javascript"">")
oSb.Append("alert('Duplicate Employee ID Found')")
oSb.Append("</script>")'if no duplicates found then insert form content and add an entry to database.
Else
Me.PersonFormView.InsertItem(True)
If oConn.State <> Data.ConnectionState.Open Then
oConn.Open()
End If
With oCmd
'MsgBox("test")
.Connection = oConn
.CommandText = "INSERT INTO CONTACT (CUSTOMER_ID, PERSON_ID, ROLE_EFF_DT, USER_DT_TM, USER_ID, ROLE_CD) " & _
"VALUES (:CUSTOMER_ID, :PERSON_ID, SYSDATE, SYSDATE, :USER_ID, :ROLE_CD)"
.Parameters.Add(":CUSTOMER_ID", OracleType.Double, 10).Value = Request.QueryString("CID")
.Parameters.Add(":PERSON_ID", OracleType.Double, 10).Value = oPersonId
.Parameters.Add(":USER_ID", OracleType.VarChar, 30).Value = Request.Cookies("NDM").Values("UserID")
.Parameters.Add(":ROLE_CD", OracleType.VarChar, 6).Value = oAcc.SelectedValue
.ExecuteNonQuery()
End With
oConn.Close()
'oSb.Append("<button onclick=""CloseWindow(New)"" type=""button"" id=""Closebutton"">Close</button>")
oSb.Append("<script language=""javascript"" type=""text/javascript"">")
oSb.Append("CloseWindow('" + Str(oPersonId) & "')")
oSb.Append("</script>")
End If
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
' Add the javascript after the form object so that the
' message doesn't appear on a blank screen.
oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(oSb.ToString()))
Else
oSb.Append("<script language=""javascript"" type=""text/javascript"">")
oSb.Append("alert('Fields with red (*) are required!')")
oSb.Append("</script>")
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
' Add the javascript after the form object so that the
' message doesn't appear on a blank screen.
oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(oSb.ToString()))
End If
Catch ex As Exception
'Send e-mail notification of error message and build the javascript to display message on screen.
oSb = Main.ErrorNotification(ex, "An Error Occured in the Application, while updating the Person information.", Request.ServerVariables("QUERY_STRING"), "Error in Person.cmdInsert_Click().", Request.Cookies("DNM").Values("UserID"))
'Find the form object on the page so that the script can be added after the form
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
' Add the javascript after the form object so that the
' message doesn't appear on a blank screen.
oFormObject.Controls.AddAt(oFormObject.Controls.Count, New LiteralControl(oSb.ToString()))
Finally
oSb = Nothing
oFormObject.Dispose()
oCmd = Nothing
oPersonId = Nothing
oAcc = Nothing
'oSalTextBox = Nothing
oFirstTextBox = Nothing
oLastTextBox = Nothing
oEMail = Nothing
End Try
End Sub
Post a reply
Quick links
Recent activity
- Mandy Bradley replied to Loop help needed
- Chris Hsu replied to How can I execute server-si...
- anu anand.lv replied to Excel Oledb Engine and VB.NET
- Rafeeque Ahmed replied to HELP ME, URGENT RESPONSE
- anu anand.lv replied to we search the company in I...
- chandradev prasad replied to how to select item to datag...
Enter your message below
Sign in or Join us (it's free).