按钮单击时创建弹出框

时间:2013-04-16 18:46:28

标签: asp.net vb.net popup

感谢您查看我的帖子。我在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

2 个答案:

答案 0 :(得分:1)

你可以点击按钮

来调用这个javascript
<script>
function myFunction()
{
  alert("I am an alert box!");
}
</script>

答案 1 :(得分: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