停止模态截止当'OnTextChanged“火灾 [英] Stop Modal Closing When 'OnTextChanged' Fires

查看:126
本文介绍了停止模态截止当'OnTextChanged“火灾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net Web窗体应用程序和用户点击一个按钮,这然后显示在它3个字段一个模式。我添加了一个 OnTextChanged 的AutoPostBack =真正的因为我已经落后于code检查,如果名称在第一输入当前存在与否。但是,当我过了片场我的模态关闭,我需要它保持打开状态。

I have an asp.net webform application and a user clicks a button, this then displays a modal with 3 fields in it. I have added an OnTextChanged and AutoPostBack="true" as i have code behind that checks if the name entered in the first currently exists or not. but when ever i tab out the field my modal closed and i need it stay open.

我不得不与我被 Jquery的 ASP工作手风琴非常simular情况:HiddenField ,但我试图改变code无济于事。

I had a very simular situation with an accordion which i got working by Jquery and asp:HiddenField but i have tried altering the code to no avail.

部分HTML模态

<div class="form-group">
     <asp:Label ID="lblPlace" runat="server" Class="col-sm-3 control-label" Text="Place" AssociatedControlID="fldPlace" />
     <div class="col-sm-6">
          <asp:TextBox ID="fldPlace" runat="server" class="form-control" AutoPostBack="true" OnTextChanged="fldPlace_TextChanged" />
     </div>
</div>

在code,我用我的手风琴是

The code i used for my accordion was

HTML

<asp:HiddenField runat="server" ID="toKeepRemoveAccordionOpen" />
<div class="form-group">        
     <asp:Label runat="server" AssociatedControlID="txtRemoveUser" CssClass="col-sm-offset-2 col-sm-3 control-label">Enter Name To Be Removed</asp:Label>
     <div class="col-sm-3">
          <asp:TextBox runat="server" ID="txtRemoveUser" CssClass="form-control" AutoPostBack="true" OnTextChanged="txtRemoveUser_TextChanged" />
     </div>
</div>

JQuery的

$('document').ready(function ()
{
    var hdnFldId = '<%= toKeepRemoveAccordionOpen.ClientID %>';
    $("#MainContent_txtRemoveUser").on("blur", function ()
    {
        //Sets value of hidden field to show panel after postback
        $('#' + hdnFldId).val(true);
    });

    if ($('#' + hdnFldId).val() == 'true')
    {
        showPanel();
        // Resets the value
        $('#' + hdnFldId).val(false);
    }

    function showPanel()
    {
        if ($('#MainContent_txtRemoveUser').val() != '')
        {
            $('.panel-collapse').removeClass('collapse').addClass('in');
        }
    }
});

我曾尝试以下 JQuery的

$('document').ready(function () {
            var hdnFldId = '<%= toKeepRemoveAccordionOpen.ClientID %>';
            $("#MainContent_fldPlace").on("blur", function () {
                //Sets value of hidden field to show panel after postback
                $('#' + hdnFldId).val(true);
            });

            if ($('#' + hdnFldId).val() == 'true') {
                showPanel();
                // Resets the value
                $('#' + hdnFldId).val(false);
            }

            function showPanel() {
                if ($('#MainContent_fldPlace').val() != '') {
                    //$('.modal').addClass('in');
                    $('.modal').removeClass('fade').addClass('fade in');
                }
            }
        });

对于一个模式的主类是模式褪色和它的显示时,在更改为模式褪色。

The main class for a modal is modal fade and when its displayed it changes to modal fade in.

推荐答案

增加了以下我的 ASPX

JQuery的

function keepOpenSuggestPlaceModal()
{
    $('#placesModal').modal('show');
}

和增加了​​以下在我的code我的函数调用后面

and added the following to my function call in my code behind

ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "keepOpenSuggestPlaceModal();", true);

这篇关于停止模态截止当'OnTextChanged“火灾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆