Javascript 基于SQL查询的确认

Javascript 基于SQL查询的确认,javascript,.net,sql,vb.net,msgbox,Javascript,.net,Sql,Vb.net,Msgbox,我必须在.net中使用vb6Msgbox(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 us

我必须在.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
,或者有其他方法吗?

不幸的是,没有。您需要了解客户端和服务器端编程的概念

选择和删除部分是服务器端编程,而msgBox是客户端编程

当rows.count>0时,您需要在网页上创建一个按钮;然后处理按钮,单击偶数删除该行。 [编辑]我觉得我的回答不值得回答,所以我在这里添加了更多细节:

创建网页名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>
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