'Create javascript Alert before response.end() vb.net
I have a button to generate rar file then download it , i want to create an alert javascript if download success or file is exist in directory.. My code :
Using zip As New ZipFile
Dim filePaths As String() = Directory.GetFiles(Server.MapPath("~/Download/" & "/" & NameFolder))
Dim files As New List(Of ListItem)()
zip.AlternateEncodingUsage = ZipOption.AsNecessary
zip.AddDirectoryByName("MyRarFileName")
For Each filePath As String In filePaths
files.Add(New ListItem(Path.GetFileName(filePath), filePath))
zip.AddFile(filePath, "MyRarFileName")
Next
Response.Clear()
Response.BufferOutput = False
Dim zipName As String = [String].Format("MyRarFileName_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss"))
Response.ContentType = "application/zip"
Response.AddHeader("content-disposition", "attachment; filename=" + zipName)
zip.Save(Response.OutputStream)
Dim ls_Dir As New IO.DirectoryInfo(Server.MapPath("~/Download" & "/" & NameFolder))
Dim ls_GetFile As IO.FileInfo() = ls_Dir.GetFiles()
Dim ls_File As IO.FileInfo
For Each ls_File In ls_GetFile
File.Delete(ls_File.FullName)
Next
ls_Dir.Delete(True)
Response.End()
End Using
I want to call an alert javascript like below :
If DataExist > 0 Then
'My Alert
Using zip As New ZipFile
'Code for generate and download rar
End Using
End If
I have tried :
Dim myScript As String = "window.alert('Download Success !');"
ClientScript.RegisterStartupScript(Me.GetType(), "myScript", myScript, True)
and call javascript function :
<script>
function MyMessage(){
alert('Download Success');
}
</scipt>
ClientScript.RegisterStartupScript(Me.GetType(), "MyMessage", MyMessage(), True)
But alert still doesn't appears, any suggest ? Thanks you
Solution 1:[1]
Optaweb-employee-rostering is a rich example application that shows how the employee rostering problem can be solved with OptaPlanner. As such, users are expected to take inspiration from it and change the app as they need.
If you want to try the app with MS SQL, replace a JDBC driver dependency: https://github.com/kiegroup/optaweb-employee-rostering/blob/main/optaweb-employee-rostering-backend/pom.xml#L81-L84
and change the Quarkus profile: https://github.com/kiegroup/optaweb-employee-rostering/blob/main/optaweb-employee-rostering-backend/src/main/resources/application.properties#L24-L28
The Quarkus profile can be activated during the build by specifying the quarkus.profile maven property, e.g.:
mvn clean install -Dquarkus.profile=postgres
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
