ASP.NET 文本框不会失去焦点

ASP.NET textbox doesn't lose focus

本文关键字:失去 焦点 NET 文本 ASP      更新时间:2023-09-26

我有一个 asp.net 的Web应用程序。在我的.aspx页面中,我有一个小的jQuery对话框,其中包含两个文本框,我正在使用日期选择器。弹出对话框时如何删除它们的焦点。我已经尝试了互联网上发布的许多解决方案,但它们仍然保持专注,因此日期选择器显示并隐藏了我的整个对话框。

这是我弹出对话框的代码:

<script type="text/javascript">
        var dialogOpts = {
            resizable: false,
            bgiframe: true,
            maxWidth: 330,
            maxHeight: 315,
            width: 330,
            height: 315,
            autoOpen: false
        };
        $('#borrow_dialog_form').dialog(dialogOpts).parent().appendTo($("#form1"));;
        $(function () {
            $("#borrow_dialog_form").dialog({
            });
            $("#Button1").click(function () {
                $("#borrow_dialog_form").dialog("open");
                return false;
            });
        });
    </script>

这是aspx:

<div id="borrow_dialog_form" title="Borrow" style="display: none;">
            <asp:Label CssClass="labelStyle" ID="Label10" runat="server" Text="From"></asp:Label>
            <asp:TextBox ID="datepicker2" runat="server"></asp:TextBox>
        <asp:Label CssClass="labelStyle" ID="Label11" runat="server" Text="To"></asp:Label>
        <asp:TextBox ID="datepicker" runat="server"></asp:TextBox>
        <br />
        <br />
        <asp:Button Style="margin-left: 90px;" ID="borrow_item_button" runat="server" Text="Borrow item" OnClick="borrow_item_Click" />
    </div>

有人可以帮我吗?

你试过吗?

        $("#Button1").click(function () {
            $("#borrow_dialog_form").dialog("open");
            $("#datepicker").blur();
            $("#datepicker2").blur();
            return false;
        });

还是那个?

        $("#Button1").click(function () {
            $("#borrow_dialog_form").dialog("open");
            $("#borrow_item_button").focus();
            return false;
        });