Link to home
Start Free TrialLog in
Avatar of TonyReba
TonyRebaFlag for United States of America

asked on

DropDownList SelectedIndexChanged event fires twice on few Dropdowns

Could anyone explain me why txtPreppin_SelectedIndexChanged event executes twice after txtPreppin value changed, then change value in second dropdownlist txtScanner


<asp:DropDownList
                    ID="txtPreppin" runat="server" CssClass="padding-input"
                    AutoPostBack="True" onselectedindexchanged="txtPreppin_SelectedIndexChanged">
                    <asp:ListItem Text="-Select-" Value=''>-Select-</asp:ListItem>
                    <asp:ListItem>Acevedo, Noe</asp:ListItem>
.
.
.
.
.
                                   </asp:DropDownList>
                <br />
                <label for="recordtype">
                                 Date:</label><asp:TextBox ID="txtprepDate" runat="server"
                    Enabled="False" ReadOnly="True"></asp:TextBox>
                <asp:CalendarExtender ID="txtprepDate_CalendarExtender" runat="server"
                    Enabled="True" TargetControlID="txtprepDate" Format="MM/dd/yyyy">
                </asp:CalendarExtender>
               
               
               
        </td>
        <td style="width: 306px">
           
        <label for="recordtype">
                                 Scanner:</label><asp:DropDownList
                ID="txtScanner" runat="server" CssClass="padding-input"
                AutoPostBack="True" onselectedindexchanged="txtScanner_SelectedIndexChanged">
                    <asp:ListItem Text="-Select-" Value=''>-Select-</asp:ListItem>
                     <asp:ListItem>Bueno, Nancy</asp:ListItem>
.
.
.
.
.
                               </asp:DropDownList>
       
                <label for="recordtype">
                                 Date:</label>
                                 <br />
                                 <asp:TextBox ID="txtScanDate" runat="server"
                Enabled="False" ReadOnly="True"></asp:TextBox>
                <asp:CalendarExtender ID="txtScanDate_CalendarExtender" runat="server"
                    Enabled="True" TargetControlID="txtScanDate" Format="MM/dd/yyyy">
                </asp:CalendarExtender>
                         





 protected void txtScanner_SelectedIndexChanged(object sender, EventArgs e)
    {

        if (Page.IsPostBack)
        {

           
            if (txtScanner.SelectedItem.Text != null)
            {
                txtScanDate.Enabled = true;
                txtScanDate.ReadOnly = false;
                txtScanDate.Text = DateTime.Today.ToString("MM/dd/yyy");
            }

            else
            {
                txtScanDate.Enabled = false;
                txtScanDate.ReadOnly = true;
            }

        }
    }
    protected void txtPreppin_SelectedIndexChanged(object sender, EventArgs e)
    {


        if (Page.IsPostBack)
        {
           
            if (txtPreppin.SelectedItem.Text != null)
            {
                txtprepDate.Enabled = true;
                txtprepDate.ReadOnly = false;
                txtprepDate.Text = DateTime.Today.ToString("MM/dd/yyy");
            }

            else
            {
                txtprepDate.Enabled = false;
                txtprepDate.ReadOnly = true;
            }
        }
    }
ASKER CERTIFIED SOLUTION
Avatar of Lalit Chandra
Lalit Chandra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TonyReba

ASKER

View state is enabled.
Thasts not the problem.
View state is enabled.
Thasts not the problem.
View State was enabled on the page, but not on the masterpage.....
Viewstate wasnt enabled on Master Page