0

并感谢您查看我的帖子。我有一个在 Visual Studio 2010 中完成的 vb 项目。一旦用户单击提交按钮,我想要一个包含特定文本的弹出消息。我还想要一个确定和取消按钮。如果用户单击确定,则页面正常运行并提交。单击取消,页面返回以供用户编辑信息。

现在,我尝试使用 msgbox,但它在服务器端不起作用。从研究中,我发现我很可能需要使用 Jquery。我对此没有太多经验,因此不胜感激!

谢谢,

乔什

Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

    If (Not Page.IsPostBack) Then
        Me.btnSubmit.Attributes.Add("onclick", "return confirm('Please note that what you have entered will be used to auto-generate the flyer. Also, submissions less than 30 days from the date entered may be denied.');")
    End If

    Dim objRequestID As Object = Nothing
    Dim intRequestID As Integer = 0

    Try
        If ValidateForm() Then
            Using objConnection As SqlConnection = util.GetConnection()
                Using objTransaction As SqlTransaction = objConnection.BeginTransaction
                    Using objCommand As SqlCommand = New SqlCommand("Request_Insert", objConnection)
                        With objCommand
                            .CommandType = Data.CommandType.StoredProcedure
                            .Transaction = objTransaction
                            .Parameters.Add("@CourseTypeID", Data.SqlDbType.Int).Value = util.CourseRequestType.PIE
                            .Parameters.Add("@SponsorName", Data.SqlDbType.NVarChar, 50).Value = SponsorName.Text.Trim
                            .Parameters.Add("@SponsorPhone", Data.SqlDbType.NVarChar, 20).Value = SponsorPhone.Text.Trimenter code here
4

2 回答 2

1

您需要将client button onclick事件放在server Page_Load事件中。

当你到达时btnSubmit_Click,为时已晚。

Protected Sub Page_Load(ByVal sender As System.Object, 
   ByVal e As System.EventArgs) Handles MyBase.Load

   If (Not Page.IsPostBack) Then
      Me.btnSubmit.Attributes.Add("onclick", "return confirm('Please...');")
   End If

End Sub
于 2013-04-16T20:20:02.483 回答
1

您可以在单击按钮时调用此 javascript

<script>
function myFunction()
{
  alert("I am an alert box!");
}
</script>
于 2013-04-16T20:09:55.407 回答