目前在我的可视化WebPart包含更新面板中,但它无法正常工作,它会回发整个页面
我的代码 我的.aspx代码
<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>
**点击提交按钮后,它回发总页面**
答案 0 :(得分:0)
默认情况下,您的保存按钮位于 UpdatePanel 中,您应该使用UpdatePanel的 ChildrenAsTriggers 属性(默认设置为 true )并且不是 AsyncPostBackTrigger 。
编辑:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
//...
</ContentTemplate>
</asp:UpdatePanel>
没有外部触发仅将子项作为触发器,默认值为 ChildrenAsTriggers 为True,相当于:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">