0

如果有人插入新的客户/类别等,我想要某种显示:“成功保存”的小屏幕。我知道有:OnClientClick="return confirm (text)"但这并不是我要找的地方。

我的代码:

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim dbconn As SqlConnection
    Dim dbcomm As SqlCommand
    Dim strsql, Categorie, Klant, Website, Titel, Naslag As String

    Categorie = DropDownCat.SelectedValue.ToString
    Klant = DropDownList1.SelectedValue.ToString
    Website = TextBoxWebsite.Text
    Titel = TextBoxTitel.Text
    Naslag = TextBoxslag.Text

    dbconn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlString"))
    dbconn.Open()

    strsql = "INSERT INTO tbl_Project (KlantID, Titel, Naslag, Website, CatID) VALUES ('" + Klant + "','" + Titel + "','" + Naslag + "','" + Website + "','" + Categorie + "')"
    dbcomm = New SqlCommand(strsql, dbconn)
    dbcomm.ExecuteNonQuery()

    dbconn.Close()

End Sub
4

1 回答 1

1

您可以在插入后向页面添加一些 javascript。

当页面完成加载时,这将显示一个简单的 Javascript 警报。

像这样的东西:

Dim cs As ClientScriptManager = Page.ClientScript
            cs.RegisterStartupScript(Me.GetType(), "thanks", "alert('Thank you for inserting bla bla');", True)

您可以将插入内容包装在一个try catch块中,并根据结果吐出不同的消息。

于 2013-04-16T14:58:26.910 回答