简体   繁体   中英

Child Update Panel don't to get refresh

I have problem in nested update panel. I binding the gridview by using user control and my listbox is in the child update panel while selecting the items in listbox the page is getting refresh. but I don't want to get refresh.

Here is my aspx:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SearchModule._Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <link type="text/css" rel="stylesheet" href="Defaultstylesheet.css" />


    <script src=<%--"Scripts/jquery-1.8.2.js" type="text/javascript"> </script>  --%>

    <%@ Register TagPrefix="inc" TagName="sPager" Src="~/UserControls/SearchPager.ascx" %>

    <asp:UpdatePanel ID="upseachr" runat="server" >
        <ContentTemplate>
    <div style="height: 50px;"></div>
    <div class="searchtextbx">
        <asp:TextBox ID="searchtext" runat="server"></asp:TextBox>
        <asp:Button ID="Search" OnClick="Search_Click"  CssClass="searchbtn" Text="Search"  height="32"  runat="server"> </asp:Button>


    </div>

             <asp:UpdateProgress ID="updatesearchpro" AssociatedUpdatePanelID="upseachr" runat="server" >
        <ProgressTemplate>
           <center>
             <asp:Panel ID="searchpanel" runat="server"> 
               <img alt="Processing" src="Images/359.gif" />
                <br />
                  <asp:Label ID="panlab" runat="server" Text="Processing..."></asp:Label>
             </asp:Panel>
           </center>  
        </ProgressTemplate>
    </asp:UpdateProgress> 



       <asp:UpdatePanel ID="updFilters" runat="server"  >

                                  <ContentTemplate>
    <div class="resultpage" style="overflow-x: scroll;">
        <table>
            <tr>

                   <div class="listbox">

                    <asp:Label ID="headertext" runat="server" CssClass="labelresul" Font-Bold="true" Height="50" Text="Available Filter"></asp:Label>
                    <span style="padding-left:10px;font-weight:700;"> <asp:HiddenField runat="server" ID="hdCount" /><asp:Label ID="Total" runat="server" Height="50"></asp:Label></span><span style="padding-left:5px;font-weight:700;"><asp:Label runat="server" ID="match" Visible="false" Text="Matches"></asp:Label>&nbsp;&nbsp;&nbsp;<asp:Label ID="remainingcount" ForeColor="Red" Visible="false" runat="server"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="remaining" runat="server" ForeColor="Red"  Text="Remaining"  Visible="true"></asp:Label>&nbsp;&nbsp;</span>

                </div>

            </tr>

            <tr>             
                <asp:ListView ID="ListView1" runat="server" OnItemDataBound="ListView1_ItemDataBound" EnableViewState="false">
                    <ItemTemplate>
                        <td>
                            <asp:Label ID="listheader" runat="server" Text='<%# Eval("additional_info_name1") %>'></asp:Label>
                                <asp:ListBox ID="results" Width="200" Visible="true" runat="server"  SelectionMode="Multiple" AutoPostBack="true" OnSelectedIndexChanged="results_SelectedIndexChanged" ></asp:ListBox>
                        </td>

                    </ItemTemplate>
                </asp:ListView>




            </tr>
            <tr>
                <td class="listbox1">
                    <asp:Button ID="btn" runat="server" Font-Size="12" Font-Bold="true" CssClass="searchbtn" OnClick="btn_Click" Text="Apply Filter" />
                </td>
            </tr>
        </table>
    </div>
                                        </ContentTemplate>

                                </asp:UpdatePanel>  


    <div style="height: 40px;"></div>

    <div class="resultpage" style="overflow-y: scroll;">
         <asp:UpdatePanel ID="updPager" runat="server">
                                    <ContentTemplate>

        <inc:sPager ID="sPager" runat="server" OnPageIndexChanging="sPager_OnPageIndexChanging"></inc:sPager>
 </ContentTemplate>
                                </asp:UpdatePanel>


          <asp:UpdatePanel ID="updGrid" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
                                        <ContentTemplate>
        <asp:GridView ID="gvResults" runat="server" AutoGenerateColumns="false" ItemStyle-VerticalAlign="Middle"  AllowSorting="true"
            ItemStyle-HorizontalAlign="Center" GridLines="None" CellSpacing="10" CellPadding="2" AllowCustomPaging="true"  OnSorting="gvResults_Sorting"
            AllowPaging="True" PageSize="20" HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Center" 
            HeaderStyle-CssClass="GridHeader" RowStyle-HorizontalAlign="Left" CssClass="GridStyle"  >

            <Columns >
                <asp:TemplateField HeaderText="Stock Code" SortExpression="manufacturer_part_number" >
                    <ItemTemplate>
                        <asp:Label ID="lblFirstName" Text='<%# DataBinder.Eval(Container.DataItem, "manufacturer_part_number")%>' runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField DataField="Manufacturer"  SortExpression="Manufacturer" HeaderText="Manufacturer"></asp:BoundField>

                <asp:BoundField DataField="Description"  SortExpression="Description" HeaderText="Description"></asp:BoundField>

                <asp:BoundField DataField="Availability"  SortExpression="Availability" HeaderText="Availability"></asp:BoundField>
                <asp:BoundField DataField="flag_rohs"  SortExpression="flag_rohs" HeaderText="RoHS"></asp:BoundField>

            </Columns>
        </asp:GridView>


          </ContentTemplate>
                                    </asp:UpdatePanel>

    </div>
            </ContentTemplate>
    </asp:UpdatePanel>









</asp:Content>

It appears that your top-level UpdatePanel has an UpdateMode of Always (which is the default).

The MSDN documentation states:

If the UpdateMode property is set to Always , the UpdatePanel control's content is updated on every postback that originates from anywhere on the page. This includes asynchronous postbacks from controls that are inside other UpdatePanel controls and postbacks from controls that are not inside UpdatePanel controls.

You can rectify this by changing your top-level UpdatePanel control to conditional. eg:

<asp:UpdatePanel ID="upseachr" runat="server" UpdateMode="Conditional">

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM