Update Panel for States dropdown + refresh page RRS feed

  • Question

  • Hi,

    I have Country, State dropdowns on my c# page. Based on country picked, states dropdown should be populated. My page has many user entry controls ( text boxes, dropdown selections, telerik RAD grid with textboxes in ItemTemplate) etc. They can fill all those and then realise that they may need to change the country and select another state. 

    With Country dropdwon, I have set 'AutoPostBack' to true. This triggers PageLoad and then dropdown_selected index changed event. This makes user entered values to disappear on page especially from the GRID.

    I used Update Panel to do partial page load but it goes through page load event where I have written code in 

    If !postback

        do something



    THis else part is getting executed.

    I tried all update panel properties being tested.

    In Update Panel, I have States Dropdown and Button Control. I have Country dropdown outside because Country is loaded one time.

    Java script function:

    function ddlCountry_changed() {
                document.getElementById('<%= btnLoadStates.ClientID %>').click();

    <asp:DropDownList ID="ddlCountry" runat="server" CssClass="floatleft" onchange="ddlCountry_changed();" >

    <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
                                <label class="fixeddata" for="<%=ddlState.ClientID %>">State:</label>
                                <asp:DropDownList ID="ddlState" runat="server" CssClass="floatleft" >
                                 <asp:Button ID="btnLoadStates" style="display: none" runat="server" OnClick="btnLoadStates_OnClick" CausesValidation="False"/>
                                <asp:AsyncPostBackTrigger ControlID="ddlCountry" />

    Thank You

    • Moved by CoolDadTx Monday, August 27, 2018 2:53 PM ASP.NET related
    Sunday, August 26, 2018 11:20 AM

All replies