这是vb.net的代码,你参考一下吧,改为c# Dim Msgbox As System.Windows.Forms.MessageBox Dim ok As System.Windows.Forms.MessageBoxIcon = System.Windows.Forms.MessageBoxIcon.Question Dim Okcan As System.Windows.Forms.MessageBoxButtons = System.Windows.Forms.MessageBoxButtons.OKCancel Dim MsgResult As System.Windows.Forms.DialogResult = System.Windows.Forms.DialogResult.OK If (MsgResult = Msgbox.Show(" 你确认要删除吗?", "删除", Okcan, ok, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly)) Then End If
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Page.RegisterStartupScript("alert", "<script language=JavaScript>alert('" + TextBox1.Text + "');</script>") End Sub
但是这样需要从客户端到服务器传输一次数据呀?不是单纯在客户端校验啊
Dim Msgbox As System.Windows.Forms.MessageBox
Dim ok As System.Windows.Forms.MessageBoxIcon = System.Windows.Forms.MessageBoxIcon.Question
Dim Okcan As System.Windows.Forms.MessageBoxButtons = System.Windows.Forms.MessageBoxButtons.OKCancel
Dim MsgResult As System.Windows.Forms.DialogResult = System.Windows.Forms.DialogResult.OK
If (MsgResult = Msgbox.Show(" 你确认要删除吗?", "删除", Okcan, ok, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly)) Then
End If
Page.RegisterStartupScript("alert", "<script language=JavaScript>alert('" + TextBox1.Text + "');</script>")
End Sub