<div id="divAnswerHeader">
<div id="divAnswerSubHeader">
<h2><asp:Label ID="lblTotalAnsw" runat="server" Text=""></asp:Label> Answers</h2>
<div id="divTabs">
<asp:LinkButton ID="oldestAnswer" runat="server" title="Answers in the order they were given" OnClick="oldest_click">oldest</asp:LinkButton>
<asp:LinkButton ID="newestAnswer" runat="server" title="Most recent answers first" OnClick="newest_click">newest</asp:LinkButton>
<asp:LinkButton ID="votesAnswer" runat="server" title="Answers with the most votes first" OnClick ="votes_click">votes</asp:LinkButton>
</div>
</div>
</div>
<asp:UpdatePanel ID="upPnlLMList" runat="server">
<ContentTemplate>
// code.........
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="oldestAnswer" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="newestAnswer" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="votesAnswer" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
在代码后面的文件我写了........... protected void oldest_click(object sender,EventArgs e) {
}
protected void newest_click(object sender, EventArgs e)
{
}
protected void votes_click(object sender, EventArgs e)
{
}
当我点击最新,最老,投票然后page_load事件触发,而我已经定义了异步回发,所以我想阻止fire page_load事件我将如何做。
答案 0 :(得分:3)
对于部分回发,页面生命周期仍然完好无损。 Page_Load仍然是按照设计进行解雇。
http://encosia.com/2007/10/24/are-you-making-these-3-common-aspnet-ajax-mistakes/
你可以做的是在你的Page_Load事件处理程序中,检查你是否处于部分回发的中间。
if (ScriptManager.GetCurrent(this).IsInAsyncPostBack)
答案 1 :(得分:0)
Page_Load
事件将始终触发,您可以尝试将代码包装在
if(HttpContext.Current.Request.Headers [“x-microsoftajax”] == null)
{
//你的代码在这里 }