Home > front end >  Cannot use Msgbox in ASP.net, so have to use JS to give tips, please Confirm how to write?
Cannot use Msgbox in ASP.net, so have to use JS to give tips, please Confirm how to write?

Time:11-02

With VB.Net ASP.net application development, on the server after completion of execution, silently, because you can't use msgbox to hint, can only use JS script to hint, the following
Private Sub cmdSave_Click (sender As Object, As EventArgs e) Handles cmdSave. Click
Dim strInfo as string
If saveInfo ()=True Then
MsgBox (" successfully saved ", vbInformation msgTitle) 'wanted to write, so can be in after the release of can't use, changed to
StrInfo="save data into"
ClientScript. RegisterStartupScript (Page. GetType (), "Show", "alert ('" & amp; StrInfo & amp; "');" , True)
End the If
End Sub
This code is successful, now want to achieve in advance to the user to confirm, the following code
Private Sub cmdDel_Click (sender As Object, As EventArgs e) Handles cmdDel. Click
Dim strInfo as string
If MsgBox (" sure you want to delete?" , vbYes + vbQuestion)=vbNo Then
'this code with JS calls to how to realize the above? If the user selects, retreat to the process, does not perform the following delete
The Exit Sub
End the If

If saveInfo ()=True Then
StrInfo="successful delete"
ClientScript. RegisterStartupScript (Page. GetType (), "Show", "alert ('" & amp; StrInfo & amp; "');" , True)
End the If
End Sub
  • Related