locked
Dropdown style broken inside UpdatePanel RRS feed

  • Question

  • User-1274233151 posted

    I have 2 dropdownlist within the updatepanel when I select a item from dropdownlist another list change according to another ddl. But that's time I lost my style of dropdownlist

    This is my aspx code

    <asp:UpdatePanel runat="server" ID="pnlModalFirst" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <div class="modal-body">
                                        <asp:DropDownList runat="server" CssClass="selectpicker markaselect margin-bottom-10" ID="ddlBrand" ClientIDMode="Static" DataValueField="Id" DataTextField="BrandName" AutoPostBack="True" OnSelectedIndexChanged="ddlBrand_SelectedIndexChanged" title="Marka Seçiniz" data-live-search="true" />
                                        <asp:DropDownList runat="server" CssClass="selectpicker modelselect margin-bottom-10" ID="ddlModel" ClientIDMode="Static" AutoPostBack="True" OnSelectedIndexChanged="ddlModel_SelectedIndexChanged" title='Model Seçiniz' />
                                        <asp:DropDownList runat="server" CssClass="hidden selectpicker margin-bottom-10" ID="ddlKaroser" title='Karoser Seçiniz' />
                                        <asp:Button runat="server" CssClass="col-md-2 btn-block btn-u btn-u-blue btn-u-lg " ID="btnDKnow" Text="Teklifleri Al" OnClick="btnDKnow_Click" ValidationGroup="modalKnow" />
                                    </div>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="ddlBrand" EventName="SelectedIndexChanged" />
                                    <asp:AsyncPostBackTrigger ControlID="ddlModel" EventName="SelectedIndexChanged" />
                                </Triggers>
                            </asp:UpdatePanel>

    And also I use [this] plugin my dropdownlist but when I change first ddl all style broken like this

    Before select ddl

    After select ddl

    Tuesday, March 25, 2014 12:19 PM

Answers

  • User-760709272 posted

    The javascript plug in runs when your page loads and attaches to dropdowns already on the page.  When the updatepanel fires it replaces the dropdowns that were previoiusly there with new ones that haven't been processed by your plug in.  Rather than calling the $('#dynamic').selectric(); code on document ready, put it in a function and use ScriptManager.RegisterStartupScript in your code-behind.  That will generate js that not only calls the code when the page loads, but also when the updatepanel fires.

    http://stackoverflow.com/questions/5412120/call-a-javascript-function-after-updatepanel-postback-issue

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 25, 2014 12:36 PM

All replies

  • User-760709272 posted

    The javascript plug in runs when your page loads and attaches to dropdowns already on the page.  When the updatepanel fires it replaces the dropdowns that were previoiusly there with new ones that haven't been processed by your plug in.  Rather than calling the $('#dynamic').selectric(); code on document ready, put it in a function and use ScriptManager.RegisterStartupScript in your code-behind.  That will generate js that not only calls the code when the page loads, but also when the updatepanel fires.

    http://stackoverflow.com/questions/5412120/call-a-javascript-function-after-updatepanel-postback-issue

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 25, 2014 12:36 PM
  • User-1274233151 posted

    you'r my HERO :) Thanks MAN!!!

    Tuesday, March 25, 2014 12:45 PM