简体   繁体   中英

AsyncPostBackTrigger not working in Update Panel

Currently in my visual WebPart Contains update panel , but it not working, it post back the whole page

my code My .aspx code

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

<ContentTemplate>
    <div>
        <div class="leftSection">
            <asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="True">
                <asp:ListItem Text="2015" Value="2015"></asp:ListItem>
                <asp:ListItem Text="2016" Value="2016"></asp:ListItem>
            </asp:DropDownList>
    <div class="frmDate"><p>From</p>
        <SharePoint:DateTimeControl ID="from" runat="server" DateOnly="True" AutoPostBack="true" MaxDate="8900-12-31" MinDate="2015-07-31"  OnDateChanged="from_DateChanged" Calendar="1" IsRequiredField="true"  ErrorMessage="Please Select From Date"/>
    </div>
        <div class="lastDate">
            <p>
                To
            </p>
            <SharePoint:DateTimeControl ID="to" runat="server" DateOnly="True" OnDateChanged="to_DateChanged" AutoPostBack="true"  OnValueChangeClientScript="holidayDates()" IsRequiredField="true" ErrorMessage="Plaese Select To Date" />

        </div>
            </div>
        <div class="rightSection">
        <div  id="testdiv" runat="server">

        </div>
            <asp:Label CssClass="hdn-lbl lblFromDate" ID="lblFromDate" runat="server" Text="Label"></asp:Label>
            <asp:Label CssClass="hdn-lbl lblToDate" ID="lblToDate" runat="server" Text="Label"></asp:Label>
            <asp:Label CssClass="hdn-lbl lblTotalHrs" ID="lblTotalHrs" runat="server" Text="Label"></asp:Label>

            <asp:Button ID="save" runat="server" Text="SUBMIT" OnClientClick="return cal()" OnClick="save_Click" />
            </div>

    </div>
</ContentTemplate>
<Triggers>

   <asp:AsyncPostBackTrigger ControlID="save" />

 </Triggers>

 </asp:UpdatePanel>

**after click on Submit Button it Post back total page **

Your save button is in your UpdatePanel by default you should use the ChildrenAsTriggers property of your UpdatePanel (set to true by default) and not AsyncPostBackTrigger .

Edit:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    //...
</ContentTemplate>
</asp:UpdatePanel>

No external triggers just children as triggers, and default value as ChildrenAsTriggers is True equivalent to :

<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">

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