locked
How to wrap button in updatepanel RRS feed

  • Question

  • User1652530521 posted

    Hi,

    I have a table with a few dropdownlist controls with autopostack=true and a submit button. When submit button is clicked Gridviews are populated.

    However, I don't know how to wrap the buttons in an updatepanel so that the top part of the page where the dropdownlists are isn't refreshed when buttons (cmdsearch and cmdReset) are clicked.

    <asp:UpdatePanel ID="upFund" runat="server" UpdateMode="Conditional">
                                        <ContentTemplate>
                                           <asp:DropDownList ID="drpFund" runat="server" Width="160px" AutoPostBack="true">
                                            
                                            </asp:DropDownList>
                                        </ContentTemplate>
                                        <Triggers>
                                           <asp:AsyncPostBackTrigger ControlID="drpFund" EventName="SelectedIndexChanged"/>
                                        </Triggers>
                                    </asp:UpdatePanel>
    
     
    
     <asp:UpdatePanel ID="updatePanelProps" runat="server">
                            <ContentTemplate>
                                
                                    <table id="tblProps" cellpadding="2" cellspacing="0" runat="server">
                                        <tr>
                                            <td style="width: 130px">
                                                <asp:RadioButton ID="chklsCutIsFundNumber" runat="server" AutoPostBack="true" GroupName="grpCriteria"
                                                    Text="search by fund number" />
                                            </td>
                                            <td>
                                                <cc1:ValidateTextBox ID="txtCutFundNumber" runat="server" CompareType="Integer" ></cc1:ValidateTextBox>
                                               
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:RadioButton ID="chklsCutIsFreeText" runat="server" AutoPostBack="true" GroupName="grpCriteria"
                                                    Text="Free search" />
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="drpCutSearchByCategory" runat="server" AutoPostBack="true"    Width="150px">
                                                   
                                                </asp:DropDownList>
                                               <asp:TextBox ID="txtCutSearch" runat="server" Width="115px" MaxLength="255"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:RadioButton ID="chklsCutFundHasProperties" runat="server" AutoPostBack="true"
                                                    GroupName="grpCriteria" Text="search by properties" />
                                            </td>
                                            <td>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style3">
                                              Company
                                            </td>
                                            <td class="style3">
                                                <asp:DropDownList ID="drpManagement" Width="350px" runat="server" AutoPostBack="True"> 
                                                </asp:DropDownList>
                                                
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                               operator
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="drpOperator" Width="350px" runat="server" AutoPostBack="True">
                                                   
                                                </asp:DropDownList>
                                               
                                                    </td>
                                        </tr>
                                        <tr>
                                            <td>
                                            </td>
                                            <td>
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                            </ContentTemplate>
                        </asp:UpdatePanel>
    
       <table>
                            <tr>
                                <td>
                                
                                    <asp:Button ID="cmdSearch" runat="server" Text="search" ValidationGroup="vgrp" />
                                    <asp:Button ID="cmdReset" runat="server" Text="reset"  CausesValidation="false" />
                                    <asp:Label ID="lblErrorMessage" runat="server" ForeColor="Red"></asp:Label>
                                  
                                </td>
                                <td class="style5">
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
    
    ---3 gridviews each wrapped in each own updatepanel
      <asp:UpdatePanel ID="upCompanies" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div id="divCompanies" runat="server" class="divScroll">
                                    <table>
                                        <tr>
                                            <td>
                                                <asp:GridView ID="grdCompanies">
    ------
        </ContentTemplate>
                        </asp:UpdatePanel>

    Thursday, July 30, 2015 3:22 AM

Answers

  • User1724605321 posted

    Hi whisky ,

    You could add UpdateMode="Conditional" to your UpdatePanel and add "Triggers" tag to your UpdatePanel ,code below is for your reference:

           <asp:UpdatePanel ID="updatePanelProps" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:DropDownList ID="drpFund" runat="server" Width="160px" AutoPostBack="true">
                     </asp:DropDownList>
                </ContentTemplate>
                <Triggers>
                   <asp:AsyncPostBackTrigger ControlID="cmdSearch" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>

    For more information ,please refer to link below:

    http://www.asp.net/web-forms/overview/older-versions-getting-started/aspnet-ajax/understanding-asp-net-ajax-updatepanel-triggers .

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 30, 2015 10:12 PM