我有一个包含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