Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Passing results from confirm() back to sub procedure


Message #1 by "Patterson, Stephanie L" <stephanie.l.patterson@i...> on Wed, 3 Jul 2002 15:31:29 -0700
Using the following sub procedure, I create a confirm popup window.  How do
I pass back to the calling DoItemDelete sub procedure (also shown below)
which button is clicked (OK or Cancel)?  I want to make sure they really do
want to delete the record.  The DoItemDelete is called via the EditTemplate
of DataList1.

  Sub DoConfirm(strMsg As String)
    Dim strMsgBox as String
    strMsgBox  = "<scr" & "ipt language=""JavaScript""
type=""text/javascript"">" & vbCrlf
    strMsgBox &= "  confirm('" & strMsg & "');" & vbCrlf
    strMsgBox &= "</scr" & "ipt>"
    Response.Write(strMsgBox)
  End Sub 'DoConfirm(strMsg As String)

  Sub DoItemDelete(objSource As Object, objArgs As DataListCommandEventArgs)
    
    DoConfirm("Do you really want to DELETE this record?")
    
    '******* if confirmed continue with following ******
    'create a suitable SQL statement and execute it
    Dim strSQL As String
    strSQL  = "DELETE product_data " 
    strSQL += "WHERE prod_id = '" &
DataList1.DataKeys(objArgs.Item.ItemIndex)
    strSQL += "';"
    ExecuteSQLStatement(strSQL)

    'set EditItemIndex property of grid to -1 to switch out of Edit mode
    DataList1.EditItemIndex = -1
    DataList1.DataSource = CreateDataSource()
    DataList1.DataBind()
  End Sub 'DoItemDelete


  Return to Index