2013-01-20 60 views
1

我正在關注管理瀏覽器歷史記錄asp.net示例文章,但在單擊瀏覽器後退按鈕後更新LabelHistoryData標籤時出現問題。我把一個斷點Ajax +瀏覽器歷史記錄

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); 
      } 

回答

0

原來,UpPanel UpdateMode必須設置爲Always。