简体   繁体   中英

ASP.NET textbox doesn't lose focus

I have a asp.net web application. In my .aspx page I have a small jQuery dialog with two textboxes for which I am using a 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:

<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;
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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