本文介绍了下拉回发两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在"ddl_SelectedIndexChanged"上放置了一个断点.
我意识到...代码被调用了两次.这会影响我有用的功能.

注意:由于某些原因,我无法使用UpdatePanel.

我的代码类似于以下内容:

I have place a break-point on ''ddl_SelectedIndexChanged''
I realize...code is calling twice. This effects my useful functionality.

Note: I can not use UpdatePanel because of some reason.

My code is similar to below:

$(document).ready(function(){
    SetOnChange();
});
var fieldChange=false;
var postBack='0';
function SetOnChange()
{
    var $inputs = $("#aspnetForm :input");
    $inputs.each(function() {
        if(this.id.indexOf('__')<0)
        {
            if(this.id.indexOf('_ddl')>0 && this.className.indexOf('post')>0)
            {
                $(this).change(function() { postBack='1'; });
            }
            else
            {
                $(this).change(function() { 
                    fieldChange=true;
                });
            }
        }
    });
}







<asp:DropDownList ID="ddl" TabIndex="1" runat="server" CssClass="dropdowns post"

                                                                                    Style="width: 290px;" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged" >
                                                                                </asp:DropDownList>





protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
        {
//some code here
        }



请帮忙.预先表示感谢.



Please help. Thanks in advance.

推荐答案




这篇关于下拉回发两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 22:45