我有一個包含Repeater的UpdatePanel。在轉發器的ItemTemplate中有一個按鈕和一個標籤。在更新面板內的中繼器內不可見標籤
當按鈕被按下時,它執行一些功能,然後將標籤設置爲可見並禁用該按鈕。
但是沒有任何UI更改正在對網頁進行。
下面是代碼,這在調試器步進經過時似乎很好地工作:
protected void CommentRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "report")
{
(e.Item.FindControl("btnReportComment") as ImageButton).Enabled = false;
Label thanksLabel = (Label)e.Item.FindControl("lblReportedComment");
thanksLabel.Visible = true;
}
pnlCommentsUpdater.Update();
}
以及頁面的代碼(不包括中繼器之外的代碼)
<asp:UpdatePanel UpdateMode="Conditional" ID="pnlCommentsUpdater" runat="server">
<ContentTemplate>
<asp:LinkButton ID="lnkPhoto1Comments" runat="server" Text="0 Comments" OnClick="lnkPhoto1Comments_Click" CssClass="dark-gray regular bold"></asp:LinkButton>
<asp:Panel ID="pnlPhoto1Comments" runat="server" Visible="False">
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="CommentRepeater_ItemCommand">
<ItemTemplate>
<br />
<hr width="100%" size="1" color="#CCCCCC" />
<table width="534" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="150" align="left" valign="top">
<span class="blue small bold"><%# Eval("PostedBy") %>,</span><br />
<span class="light-gray small bold"><%# Eval("DateCreated", "{0:g}") %></span>
</td>
<td width="20"></td>
<td width="252" align="left" valign="top">
<div STYLE="word-wrap:break-word;width:252px;left:0">
<span class="dark-gray small bold"><%# Eval("CommentText") %></span>
</div>
</td>
<td width="20"></td>
<td width="92" valign="bottom">
<asp:ImageButton ID="btnReportComment" runat="server" ImageUrl="../images/inappropriate_off.png" CssClass="domclickroll images/inappropriate_on.png images/inappropriate_on.png" AlternateText="Inappropriate" CommandName="report" CommandArgument='<%#Eval("CommentId") %>' /><br />
<asp:Label ID="lblReportedComment" runat="server" Visible="false" CssClass="Regular bold blue" Text="Thanks. We'll check it out!"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
正如我所說的,調試器顯示它工作正常,但它不會在單擊按鈕後在瀏覽器中顯示標籤。
任何人都知道我在做什麼錯了?
錯誤是:「Sys.WebForms.PageRequestManagerParserErrorException:無法解析從服務器收到的消息。此錯誤的常見原因是通過調用Response.Write(),響應過濾器,HttpModules ,或者服務器跟蹤已啓用。「
我打電話來
ScriptManager.GetCurrent(Page).RegisterPostBackControl(Repeater1);
在頁面加載,這是我在一些網站閱讀
是解決方案,但它並沒有幫助。
在什麼事件處理程序中,我可以調用RegisterPostBackControl,找到關於它的一點信息。 – 2009-12-17 18:14:52
明白了,謝謝! – 2009-12-18 02:44:30