Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OnClientClick jQuery弹出javascript后未触发按钮onclick_Javascript_C#_Jquery_.net_Onclick - Fatal编程技术网

OnClientClick jQuery弹出javascript后未触发按钮onclick

OnClientClick jQuery弹出javascript后未触发按钮onclick,javascript,c#,jquery,.net,onclick,Javascript,C#,Jquery,.net,Onclick,我有一个c#.net页面,其中有一个按钮控件,带有OnClientClick,通知用户他们将提交一些收集的信息。以及一个OnClick事件,该事件执行一些验证,然后将信息写入数据库 jquery弹出窗口显示出来,但如果选择了“是”,我需要它来运行OnClick事件。但事实并非如此。如果我添加返回true对于jQuery脚本的“是”部分,它似乎会触发单击,从而启动OnClientClick,弹出窗口再次显示。我已经尝试过\uu dopostback,但没有成功 单击弹出窗口上的“否”,弹出窗口消失

我有一个c#.net页面,其中有一个按钮控件,带有
OnClientClick
,通知用户他们将提交一些收集的信息。以及一个
OnClick
事件,该事件执行一些验证,然后将信息写入数据库

jquery弹出窗口显示出来,但如果选择了“是”,我需要它来运行
OnClick
事件。但事实并非如此。如果我添加
返回true
对于jQuery脚本的“是”部分,它似乎会触发单击,从而启动
OnClientClick
,弹出窗口再次显示。我已经尝试过
\uu dopostback
,但没有成功

单击弹出窗口上的“否”,弹出窗口消失,并且未触发
OnClick
,这是所需的效果。只需获取“是”部分即可触发
OnClick
事件(
OnClick\u btnsubmitembiddetails

.net按钮控件:

            <div id="msgDialogAlert" style="display: none; text-align: center; vertical-align: central">
            <p id="operationMsgAlert">&nbsp;</p>
        </div>
        <asp:Button ID="btnSubmitItemBidDetails" runat="server" Text=" Submit Bid " OnClick="OnClick_btnSubmitItemBidDetails" CssClass="btn btn-primary" OnClientClick="return ShowMessage();" UseSubmitBehavior="false" />
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
    function ConfirmBox(msgtitle, message, controlToFocus) {
        $("#msgDialogAlert").dialog({
            autoOpen: false,
            modal: true,
            title: msgtitle,
            closeOnEscape: true,
            buttons: [{
                text: "Yes",
                click: function () {
                    $(this).dialog("close");
                    if (controlToFocus != null)
                        controlToFocus.focus();
                    //-- do whatever you wanted to code if user click yes here

                    return true;
                }
            },
                {
                    text: "No",
                    click: function () {
                        $(this).dialog("close");
                        if (controlToFocus != null)
                            controlToFocus.focus();
                        //-- do whatever you wanted to code if user click no here
                    }
                }],
            close: function () {
                $("#operationMsgAlert").html("");
                if (controlToFocus != null)
                    controlToFocus.focus();
            },
            show: { effect: "clip", duration: 200 }
        });
        $("#operationMsgAlert").html(message);
        $("#msgDialogAlert").dialog("open");
    };

    function ShowMessage() {
        ConfirmBox("Message Box Title", "Message box text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text.", null);
        return false;
    }
</script>
public void OnClick_btnSubmitItemBidDetails(object sender, EventArgs e)
{
    bool isError = false;
    lblSubmitBidErrors.Text = "";

    string strMyTableId = "1";
    string strMyTableText = tbxText.Text.ToString().Trim();

    if (strMyTableText .ToString().Trim().Length == 0)
    {
        isError = true;
        lblSubmitBidErrors.Text += "You must enter some text.<br />";
    }

    if (!isError)
    {
        SqlConnection objConn = new SqlConnection(strConnString);
        objConn.Open();
        string sSQL = "INSERT INTO myTable (myTableId, mTableText, myTableDateTime) VALUES (" + strMyTableId + ",'" + strMyTableText + "', '" + DateTime.Now.ToString() + "');";
        SqlCommand objCmd = new SqlCommand(sSQL, objConn);
        objCmd.ExecuteNonQuery();
    }
}