将变量从vb或javascript元素放入onclientclick aspx

时间:2017-04-12 02:53:27

标签: javascript asp.net vb.net

这是aspx中的日期数据文本框

<asp:TextBox runat="server" ID="datepicker" AutoPostBack="true"></asp:TextBox> &emsp;

我想要做的是当我点击按钮时,对话框确认框显示如下这个词

  

“没有为'12 / 4/2017'发货,确定要保存记录吗?”

                   Ok Cancel

现在这是在同一个aspx文件中的按钮

    <asp:Button runat="server" ID="btnUpNoDelivery" 
      Text="No Delivery" 
      OnClientClick="return confirm('No delivery for "+ <%=datepicker.text %> +" Are you sure you want To save record')" />

这是在后面的vb

Protected Sub btnUpNoDelivery_Click(sender As Object, e As EventArgs) Handles btnUpNoDelivery.Click



        If datepicker.Text <> "" Then

            Dim lCnn As New SqlConnection
            Dim lCmd As New SqlCommand
            Dim lsCmd As String
            Dim lRd As SqlDataReader

            lCnn.ConnectionString = gsConnString
            lCnn.Open()
            lCmd.Connection = lCnn

            lsCmd = " INSERT INTO edrsDB..tbl_status"
            lsCmd &= " VALUES ('" & Session("SsionCode") & "'"
            lsCmd &= ", 'N.D'"
            lsCmd &= ", " & SQLQUOTE(Trim(datepicker.Text)) & ")"
            lCmd.CommandText = lsCmd
            lRd = lCmd.ExecuteReader
            Dim message As String = "alert('You has been Updated at date " & SQLQUOTE(Trim(datepicker.Text)) & "As No delivery')"
            ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", message, True)
            lRd.Close()
            Threading.Thread.Sleep(1000)

        Else
            lblDateError.Visible = True
            lblDateError.Text = "* Pick a date."
        End If
    End Sub

我也有这个错误

  

Handles子句需要在中定义一个WithEvents变量   包含类型或其基本类型之一

如何使日期可以在对话框中显示?

0 个答案:

没有答案