English 中文(简体)
Update Panel and partial rendering and AsyncPostBackTriggers only firing the first time with AjaxControlToolkit:ComboBox
原标题:

This should be a pretty simple thing to do with Update Panels, but I m having troubles. I want to update the updatePanelSelectedVendors on vendorsComboBox selection change, when the gridview pages, and on the delete buttons in that panel. I don t want to refresh the vendor combox at all, but I don t want to do a full post back.

The problem is that the async post back only happens the first selection change of the vendorsComboBox. I m having similar panels with other update panels in this user control. How can I link them all together and only update on the triggers I set.

<div class="containerBox vendorsSelectBox">
    <asp:Label ID="lblVendors" runat="server" EnableViewState="false" AssociatedControlID="vendorsComboBox" CssClass="labelHeader" Text="Vendors" />
    <br />
  <asp:UpdatePanel ID="updatePanelVendorsSelect" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
        <ContentTemplate>
            <ajaxToolkit:ComboBox ID="vendorsComboBox" runat="server"
                            DataTextField="Name"
                            DataValueField="VendorID"
                            AutoPostBack="true"
                            AutoCompleteMode="SuggestAppend"
                            DropDownStyle="DropDownList"
                            CssClass="CustomComboBoxStyle" 
                            CaseSensitive="false"
                            AppendDataBoundItems="false" 
                            onselectedindexchanged="vendorsComboBox_SelectedIndexChanged">
            </ajaxToolkit:ComboBox>
     </ContentTemplate>
   </asp:UpdatePanel>
</div>
<asp:Panel ID="panelSelectedVendors" runat="server" CssClass="containerBox selectedFranchiseBox">            
     <label class="labelHeader">Selected Vendors</label>&nbsp;&nbsp;&nbsp;<br />
     <asp:UpdatePanel ID="updatePanelSelectedVendors" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
         <Triggers>
            <asp:AsyncPostBackTrigger ControlID="vendorsComboBox" EventName="SelectedIndexChanged" />
        </Triggers>
        <ContentTemplate>               
                <asp:GridView ID="selectedVendorsList" runat="server"
                   AllowPaging="True"
                   Width="250"
                   DataKeyNames="VendorID" AutoGenerateColumns="False" SkinID="gridViewSkin" 
                    onrowdatabound="selectedVendorsList_RowDataBound" 
                    onpageindexchanging="selectedVendorsList_PageIndexChanging">                        
                    <Columns>
                        <asp:TemplateField HeaderText="Remove?" ItemStyle-Width="10">
                            <ItemTemplate>
                                <asp:CheckBox ID="checkBoxSelect" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                    </Columns>
                </asp:GridView>
        </ContentTemplate>
    </asp:UpdatePanel>
    <br />            
    <asp:Button ID="buttonDeleteSelectedVendor" runat="server" 
                Text="Delete Selected Vendor" EnableViewState="false"
                SkinID="button" style="display:none; float:left; width:150px;" 
                onclick="buttonDeleteSelectedVendor_Click" />
    <asp:Button ID="buttonClearSelectedVendors" runat="server"
                Text="Delete All" SkinID="button" style="float:right; margin-right:25px;" 
                Visible="false"
        onclick="buttonClearSelectedVendors_Click" />
 </asp:Panel>

EDIT: I changed vendorsComboBox to a regular DropDownList and the partial post backs worked the way I expected. Why doesn t it with the ComboBox control?

最佳回答

If you don t want to refresh vendorsComboBox , then there s no need for it to be in an UpdatePanel in the first place. Adding it as a trigger to updatePanelSelectedVendors is sufficient to update that UpdatePanel.

As far as having multiple UpdatePanels on the page is concerned, you seem to be doing the most important thing right, that is making sure they have UpdateMode="Conditional", otherwise they all update when any of them does.

Anyway, try removing the updatePanelVendorsSelect panel, as it s not necessary at all, and any others that wrap content that doesn t need to change, and see how you get on. It may solve your problem, it may slightly help, let me know.

问题回答

暂无回答




相关问题
Getting rid of Microsoft AJAX

We wrote a couple of controls using Microsoft AJAX (cs class + js class). Now I m thinking about getting rid of it (just use jQuery), as it is bloated and we don t use UpdatePanel. My question is: how ...

ASP.NET Ajax 4 and Microsoft Ajax library definitions

I undestand that is former for Web Forms ASP.Net only , latter ( currently preview 6 ) suitable for both - classic and MVC. Would it be possible to give a brief description/usage for each. By ASP.NET ...

ASP.NET Rich UI - What do you use? [closed]

I m looking for feedback on what other people use on their ASP.NET projects to provide a rich user interface experience while still remaining as productive as possible. I m developing an ASP.NET 3.5 ...

CollapsiblePanelExtender collapses on link hover

I am trying to use an CollapsiblePanelExtender to make some dropdown menus and am having some problems when hovering over links - can anyone help me out... By the way I do want to keep the ...

热门标签