我正在处理已在我们的应用程序中存在的DeleteConfirmation功能。当用户点击asp.delete按钮时,会弹出一个JavaScript窗口;然而,它只会闪现并消失。请参阅代码:注意:当我在页面加载上调用函数时,弹出窗口会显示出来。但我希望它在单击删除按钮时显示并触发删除方法/事件。
的JavaScript
var message = "Please help";
function confirmDeletePop(message) {
popmodal('/' + getAppPath() + '/sec/portal/ConfirmDeletePage.aspx?CustomMessage=' + message);
}
代码背后
Private Sub BtnButtonDelete_Click(sender As Object, e As EventArgs) 'Handles BtnButtonDelete.Click
If Not (IdentityHubPermissionDB.CheckPermission(User, IdentityHubPermissionDefinition.p_Preferences_CanUseMyDownloads) And IdentityHubPermissionDB.CheckPermission(User, IdentityHubPermissionDefinition.p_Documents_CanDeleteDocuments)) Then IdentityHubPermissionDB.NoPermissionsRedirect()
Dim rst As CallResult
Dim Downloads As Dictionary(Of String, String) = Nothing
rst = IdentityHub.SDK.IdentityHubSettings.GetDownloads(Downloads)
'local variables
Dim FileToDelete As String
Dim UploadedFilePath As String
Dim BtnButtonDelete As WebControls.Button
'command sending button
BtnButtonDelete = CType(sender, WebControls.Button)
'BtnButtonDelete.OnClientClick = "return confirmDeletePop();"
BtnButtonDelete.Attributes.Add("onclick", "confirmDeletePop();")
If rst.IsSuccess Then
Try
FileToDelete = BtnButtonDelete.Attributes.Item("LinkFile").ToString()
UploadedFilePath = Server.MapPath("~/files/" & FileToDelete)
'do the delete process
Dim PeriodStrippedFileName = FileToDelete.Replace(".", "_")
If (File.Exists(UploadedFilePath)) Then
'deletes the actual file from the files folder
File.Delete(UploadedFilePath)
'deletes a section setting on a config file
ConfigConnector.DeleteSetting("IdentityHub.List.Config", "IdentityHub.Download." & PeriodStrippedFileName)
Response.Redirect(Request.RawUrl)
End If
Catch ex As Exception
End Try
Else
CallResult.Log(CallResults.Failed_Error, rst.Message, Me)
End If
End Sub