Question

I am looking for an alternative where user doesnt has to wait for postback in an asp.net page. My situation : I have several drop down lists on my asp.net page (11 infact) and I have a checkbox. 2 drop downs are cascading. i.e. selecting 1st drop down changes the 2nd drop down contents. I have a new option in some of the dropdowns (6 drop downs). If user chooses this option then a text box shows up with a "Add" button. Adding text to that text box and hitting "Add" adds the new value to the drop down and disappears this textbox and the button. So is it possible for using a non postback option but have the same situation going on? User does not like that the page postbacks 11 times. What is my alternative? If you need more information, please ask. Thanks

EDIT:

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                                        <ContentTemplate>
                                                            <asp:DropDownList ID="ddlCustomerContact" runat="server" DataTextField="FullName" DataValueField="Customers_SourceIDfk2" AutoPostBack="true" TabIndex="1" />
                                                        </ContentTemplate>
                                                    </asp:UpdatePanel>  

   Protected Sub ddlCustomerContact_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlCustomerContact.SelectedIndexChanged
    If ddlCustomerContact.SelectedIndex = 1 Then
        divAddNewCustomerContact.Visible = True
    Else
        divAddNewCustomerContact.Visible = False
    End If
End Sub

No correct solution

OTHER TIPS

Your only real option if you don't want standard postbacks would be AJAX. There are numerous frameworks available, so you can use the Microsoft framework (bundled in 3.5+) or jQuery (also bundled in VS 2010+, I believe).

There are other frameworks available, but those two are going to be the most tightly integrated. Other frameworks will require a little more work to implement.

This is how I use an update panel for a widget that I created.

<asp:DropDownList ID="ddlPayrollStores" runat="server" OnSelectedIndexChanged="ddlPayrollStores_SelectedIndexChanged" AutoPostBack="true">
        </asp:DropDownList>
        <asp:UpdatePanel ID="UpdatePanelPayroll" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlPayrollStores" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
            </Triggers>
            <ContentTemplate>
                <div class="dragbox-content">
                    <asp:Label ID="lblLabelHours" runat="server" Text="Reg Hours: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalHours" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelOverTime" runat="server" Text="Total Overtime Hours: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalOvertime" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelHoliday" runat="server" Text="Total Holiday: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalHoliday" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelVacation" runat="server" Text="Total Vacation: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalVacation" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lbllableTotalHours" runat="server" Text="Total Hours: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalStoreHours" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <asp:Label ID="lblLabelPay" runat="server" Text="Total Pay: " Width="350px"></asp:Label>
                    <asp:Label ID="lblTotalPay" runat="server" Text=""></asp:Label>
                    <br />
                    <br />
                    <div style="align-content: center">
                        <asp:LinkButton ID="lbDetailed" runat="server" Text="Detailed Report" PostBackUrl="~/Reporting/Payroll/StorePayroll.aspx"></asp:LinkButton>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>

This is for a payroll widget that shows the store's total payroll. So when I select which store I want to see with the drop down, the update panel will post back without posting back the entire page. In my case, it will just display numbers as labels. Hopefully this leads you in the right direction and possibly clears it up a bit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top