Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

JavaScript
$(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;
                });
            }
        }
    });
}



XML
<asp:DropDownList ID="ddl" TabIndex="1" runat="server" CssClass="dropdowns post"
                                                                                    Style="width: 290px;" AutoPostBack="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged" >
                                                                                </asp:DropDownList>


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


Please help. Thanks in advance.
Posted
Comments
tanishtaman 2-Mar-12 6:23am    
Problem occurs in IE only.
tanishtaman 3-Mar-12 0:45am    
plz...reply.......... :(
Its urgent

1 solution

hi...u set AutoPostBack=true ..so it will call the AutoPostBack once and also u set a SetOnChange this will also call the ddl_SelectedIndexChanged event once...
 
Share this answer
 
Comments
tanishtaman 2-Mar-12 8:04am    
so what is the solution? I have to do both, i.e. code fire onchange (on client side) also ddl_SelectedIndexChanged to run server side code...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900