我正在关注管理浏览器历史记录 asp.net 示例文章,但在单击浏览器后退按钮后更新LabelHistoryData标签时遇到问题。我在
LabelHistoryData.Text = Server.HtmlEncode(e.State["s"]);
但不知何故,单击 btnGetInboxList 或 btnGetSentboxList 后跟浏览器后退按钮,LabelHistoryData.Text 值始终为空。下面是我的一部分代码。有人请善意建议。
谢谢。
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" OnNavigate="OnNavigateHistory" EnableHistory="true" EnableSecureHistoryState="false" />
<asp:UpdatePanel ID="uiupInboxMainGrid" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="LabelHistoryData" />
<asp:Button ID="btnGetMessageContent" runat="server" Text="MsgContent" OnClick="GetMessageContent_Click" />
<asp:Button ID="btnGetInboxList" runat="server" Text="Inbox" OnClick="GetInboxList_Click"/>
<asp:Button ID="btnGetSentboxList" runat="server" Text="OutBox" OnClick="GetSentBoxList_Click" />
</ContentTemplate>
</asp:UpdatePanel>
public void OnNavigateHistory(object sender, HistoryEventArgs e)
{
LabelHistoryData.Text = Server.HtmlEncode(e.State["s"]);
}
protected void GetInboxList_Click(object sender, EventArgs e)
{
LabelHistoryData.Text = ((Button)sender).Text;
ScriptManager.GetCurrent(this).AddHistoryPoint("s", LabelHistoryData.Text, "Entry: " + LabelHistoryData.Text);
}
protected void GetSentBoxList_Click(object sender, EventArgs e)
{
LabelHistoryData.Text = ((Button)sender).Text;
ScriptManager.GetCurrent(this).AddHistoryPoint("s", LabelHistoryData.Text, "Entry: " + LabelHistoryData.Text);
}
protected void GetMessageContent_Click(object sender, EventArgs e)
{
LabelHistoryData.Text = ((Button)sender).Text;
ScriptManager.GetCurrent(this).AddHistoryPoint("s", LabelHistoryData.Text, "Entry: " + LabelHistoryData.Text);
}