简体   繁体   English

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

[英]ASP.NET textbox doesn't lose focus

I have a asp.net web application. 我有一个asp.net Web应用程序。 In my .aspx page I have a small jQuery dialog with two textboxes for which I am using a datepicker. 在我的.aspx页面中,我有一个带有两个文本框的小jQuery对话框,我正在使用一个datepicker。 How can I remove the focus of them when the dialog pops up. 弹出对话框时,如何删除它们的焦点。 I've tried so many solutions posted on the internet and still they continue to be focused, therefore the datepicker shows and hides my whole dialog. 我已尝试在互联网上发布了这么多解决方案,但仍然会继续关注,因此日期选择器会显示并隐藏我的整个对话框。

Here is the code I have for popping the dialog: 这是弹出对话框的代码:

<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>

And here is the aspx: 这是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>

Can someone please help me with that? 有人可以帮我吗?

Did you try that? 你试过吗?

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

or that? 或者那个?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM