我有一个转发器,我已经包含在更新面板中,我在转发器外面有按钮和下拉列表。每次单击按钮或更改下拉列表中的内容时,我都不希望页面加载。 我的代码如下。我遇到了两个问题我无法解决:
1)即使我使用更新面板和触发器(btn15MIN_Click),控件也会进入Page_Load事件,所以我想在编写更新面板代码时我会出错。
2)更改dropownlist值后需要花费很多时间才能更新转发器。
<div class="MainGrid">
<asp:Timer ID="RefreshTimer" runat="server" OnTick="RefreshTimer_Tick" Enabled="True">
</asp:Timer>
<div>
<table width="100%" cellpadding="5">
<tr>
<td>
<div>
<asp:Label ID="lblEndDate" runat="server" Text="LastUpdatedDate:" Font-Bold="true"
CssClass="label" ForeColor="Black"></asp:Label>
<asp:Label ID="lblEndDateText" runat="server" CssClass="label" ForeColor="Black"></asp:Label>
</div>
<div>
<asp:Label ID="lblRefresh" runat="server" Text="Refresh Interval:" CssClass="label"
ForeColor="Black"></asp:Label>   
<asp:LinkButton ID="btn15MIN" runat="server" OnClick="btn15MIN_Click" Text="15MIN">
</asp:LinkButton> 
<asp:LinkButton ID="btn10MIN" runat="server" OnClick="btn10MIN_Click" Text="10MIN">
</asp:LinkButton> 
<asp:LinkButton ID="btn5MIN" runat="server" OnClick="btn5MIN_Click" Text="5MIN">
</asp:LinkButton> 
<asp:LinkButton ID="btn60SEC" runat="server" OnClick="btn60SEC_Click" Text="60SEC">
</asp:LinkButton> 
<asp:LinkButton ID="btn30SEC" runat="server" OnClick="btn30SEC_Click" Text="30SEC">
</asp:LinkButton> 
<asp:LinkButton ID="btnOFF" runat="server" OnClick="btnOFF_Click" Text="btnOFF">
</asp:LinkButton>
</div>
<asp:Panel ID="Panel2" runat="server">
<asp:Label ID="lblResultsDuration" runat="server" CssClass="label" ForeColor="Black">View Results since the last </asp:Label>
<asp:DropDownList ID="ddlDuration" OnSelectedIndexChanged="ddlDuration_SelectedIndexChanged"
runat="server">
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
<asp:ListItem Text="8" Value="8"></asp:ListItem>
<asp:ListItem Text="24" Value="24"></asp:ListItem>
<asp:ListItem Text="48" Value="48"></asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblResultsDuration1" runat="server" CssClass="label"> Hours </asp:Label>
</asp:Panel>
<asp:UpdatePanel ID="MainGridUpdatePanel" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btn15MIN" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlMonitorSummary" runat="server">
<ul id="monitorGallery" class="gallery ui-helper-reset ui-helper-clearfix" style="margin-top: 5px;">
<asp:Repeater ID="rptMonitorSummary" runat="server" OnItemDataBound="rptMonitorSummary_OnItemDataBound">
<ItemTemplate>
<li class="ui-widget-content ui-corner-tr">
<h5 class="ui-widget-header">
<%# Eval("Name").ToString().Length > 16 ? (Eval("Name") as string).Substring(0, 16) : Eval("Name")%>
</h5>
<div class="center">
<asp:Image Width="100px" ID="btnPerformanceImage" runat="server" Height="75px"></asp:Image>
</div>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
</div>
任何人都可以指出我在这个
上的正确方向答案 0 :(得分:1)
无论您使用什么更新面板或其他任何内容,asp.net中的每个帖子都必须触发Page_Load事件,这是asp.net的正常行为,
并尝试将下拉列表放在更新面板中,以便在更改所选项目时不会执行完整回发:
<asp:Panel ID="Panel2" runat="server">
<asp:Label ID="lblResultsDuration" runat="server" CssClass="label" ForeColor="Black">View Results since the last </asp:Label>
</asp:Panel>
<asp:UpdatePanel ID="MainGridUpdatePanel" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btn15MIN" />
<asp:PostBackTrigger ControlID="ddlDuration"/>
</Triggers>
<ContentTemplate>
<asp:DropDownList ID="ddlDuration" OnSelectedIndexChanged="ddlDuration_SelectedIndexChanged"
runat="server">
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
<asp:ListItem Text="8" Value="8"></asp:ListItem>
<asp:ListItem Text="24" Value="24"></asp:ListItem>
<asp:ListItem Text="48" Value="48"></asp:ListItem>
</asp:DropDownList>
<asp:Label ID="lblResultsDuration1" runat="server" CssClass="label"> Hours </asp:Label>
<asp:Panel ID="pnlMonitorSummary" runat="server">
<ul id="monitorGallery" class="gallery ui-helper-reset ui-helper-clearfix" style="margin-top: 5px;">
<asp:Repeater ID="rptMonitorSummary" runat="server" OnItemDataBound="rptMonitorSummary_OnItemDataBound">
<ItemTemplate>
<li class="ui-widget-content ui-corner-tr">
<h5 class="ui-widget-header">
<%# Eval("Name").ToString().Length > 16 ? (Eval("Name") as string).Substring(0, 16) : Eval("Name")%>
</h5>
<div class="center">
<asp:Image Width="100px" ID="btnPerformanceImage" runat="server" Height="75px"></asp:Image>
</div>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>