【发布时间】:2010-03-05 20:31:59
【问题描述】:
这是我的场景,我想我缺少一个简单的解决方案:我想为 MVC 应用程序中的每个删除链接添加一个确认按钮,所以当我尝试这个时:
<%= Html.ActionLink("Delete", "Delete", new { id = item.Id }, new { id = "_delete_" })%>
<asp:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="_delete_" ConfirmText="Want it or not?" />
我明白了:
Exception Details: System.InvalidOperationException: The TargetControlID of 'ConfirmButtonExtender1' is not valid. A control with ID '_delete_' could not be found.
问题是在渲染发生之前解析了 asp:ConfirmButtonExtender 控件,因此目前还没有“delete”HTML 控件。
我怎样才能做到这一点?提前致谢。
【问题讨论】: