S
Spunny
Guest
Hi,
I have Country, State dropdowns on my asp.net 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
else
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();
}
<aspropDownList ID="ddlCountry" runat="server" CssClass="floatleft" onchange="ddlCountry_changed();" >
</aspropDownList>
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<label class="fixeddata" for="<%=ddlState.ClientID %>">State:</label>
<aspropDownList ID="ddlState" runat="server" CssClass="floatleft" >
</aspropDownList>
<asp:Button ID="btnLoadStates" style="display: none" runat="server" OnClick="btnLoadStates_OnClick" CausesValidation="False"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" />
</Triggers>
</asp:UpdatePanel>
Thank You
Continue reading...
I have Country, State dropdowns on my asp.net 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
else
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();
}
<aspropDownList ID="ddlCountry" runat="server" CssClass="floatleft" onchange="ddlCountry_changed();" >
</aspropDownList>
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<label class="fixeddata" for="<%=ddlState.ClientID %>">State:</label>
<aspropDownList ID="ddlState" runat="server" CssClass="floatleft" >
</aspropDownList>
<asp:Button ID="btnLoadStates" style="display: none" runat="server" OnClick="btnLoadStates_OnClick" CausesValidation="False"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlCountry" />
</Triggers>
</asp:UpdatePanel>
Thank You
Continue reading...