我必须在.net中使用vb6
Msgbox
(vbyesno)或类似的东西。
我知道我不能使用Msgbox
而我应该使用javascript
但问题是,我必须根据查询结果提示Messagebox。
例如:
sql= "select * from users where position = 'manager' and id = '1'"
ds = getdataset(sql,db)
If ds.tables(0).rows.count > 0 Then
If MsgBox("The user is a manager, are you sure you want to delete?", vbYesNo) = vbYes Then
sql = "delete users where id = '1'"
End if
End if
这有可能吗?我可以从.net代码中调用javascript
还是有其他方法可以执行此操作?
答案 0 :(得分:0)
不幸的是不需要。您需要了解客户端和服务器端编程的概念。
选择&删除部分是服务器端编程,而msgBox是客户端编程。
[编辑]我觉得我的回答不值得回答,所以我在这里添加了更多细节:
创建一个webPage名称deleteNow.aspx:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="deleteNow.aspx.vb" Inherits="arrow_dynascreen.deleteNow" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="myForm" runat="server">
Normal webpage content
<asp:Panel ID="myConfirmationPanel" runat="server">
The user is a manager, are you sure you want to delete?<br /><br />
<asp:Button ID="btnConfirmationYes" runat="server" Text="Yes" />
<asp:Button ID="btnConfirmationNo" runat="server" Text="No" />
</asp:Panel>
</form>
</body>
</html>
然后,在Code背后,执行此操作:
Public Class deleteNow 'Or a Partial Class, depending if you are on a WebSite or WebApplication
Inherits System.Web.UI.Page
Private Sub deleteNow_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
myConfirmationPanel.Visible = False 'Set Default to always hide it.
If Not IsPostBack() Then 'Only check to display confirmation if this is not a PostBack event (ie, when user click on Yes/No button, then don't check/execute this section.
Dim sql As String = "select * from users where position = 'manager' and id = '1'"
Dim ds As Data.DataSet '= Data.Sql.getda(sql, db)
If ds.Tables(0).Rows.Count > 0 Then
myConfirmationPanel.Visible = True
End If
Else
'Do other things that do not need to wait for confirmation
End If
End Sub
Protected Sub btnConfirmationYes_Click(sender As Object, e As EventArgs) Handles btnConfirmationYes.Click
'When user click on YES, this section will delete the SQL Row
Dim sql = "delete users where id = '1'"
End Sub
Protected Sub btnConfirmationNo_Click(sender As Object, e As EventArgs) Handles btnConfirmationNo.Click
'When user click on NO, this section will hide the confirmation panel (and do nothing).
myConfirmationPanel.Visible = False
End Sub
End Class