【发布时间】:2009-12-13 21:54:05
【问题描述】:
我有一个包含中继器的 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);
在页面加载中,我在某些网站上阅读过这是解决方案,但没有帮助。
【问题讨论】:
标签: asp.net updatepanel repeater