使用repeater开发出现 回发或回调参数无效 出错
使用repeater模板开发时 添加一个按钮 点击按钮Button实现 删除功能时就出现 下问题:
回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证
在 repeater 外面点击一个按钮 不会出现此问题 。这是什么原因啊?
各位高手帮帮小弟吧。
[最优解释]
<%@ Page EnableEventValidation="true" %>
把这个改为false吧
应该是repeater里面的数据被拦截了
[其他解释]
<li style=" height:30px;"><div class="titlediv">时间</div></li>
<li style=" height:30px;"><div class="titlediv">操作</div></li>
</HeaderTemplate>
<ItemTemplate>
<li><div class="titlediv"> <%#Eval("InfoFormUserName")%> </div></li>
<li style=" width:220px; "><div style=" width:220px;">
<asp:TextBox runat="server" Text=<%#Eval("content") %> BorderStyle="None" Width="219px" TextMode="MultiLine" ReadOnly="true" Height="50px" >
</asp:TextBox></div></li>
<li ><div class="titlediv"><asp:TextBox runat="server" Text=<%#Eval("createdate")%> Width="110px" BorderStyle="None"></asp:TextBox></div></li>
<li ><div style=" margin-top:15px; text-align:center">
<asp:HyperLink ID="hplink" Font-Underline="false" runat="server" NavigateUrl=<%#"~/UserMessages.aspx?userid=" + Eval("infoformusername") + "" %>>回复</asp:HyperLink>
<asp:CheckBox ID="mycheck" runat="server">
</asp:CheckBox><asp:Button ID="bt_delete" runat="server" OnCommand="BtnDel_Click" CommandName=<%#Eval("id") %> CommandArgument="delete" Text="删除" /></div>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</div>
</asp:Panel>
[其他解释]
thanks 但是不太明白
[其他解释]
这个检验机制很容一理解。我给你举一个例子,假设你有一个数据绑定控件,它完全可能动态地出现以下CommandName:分页、选中行、删除行,假设你根本没有在页面上输出“sp1234”信息行,而仅仅是删除“xp5678”信息行,但是流氓软件通过javascript把html dom 元素中字符串xp5678修改为sp1234然后就提交了,是不是服务器就会删除错误的信息呢?
asp.net的这个 enableEventValidation 机制就是保证这种流氓行径无法执行。所以我建议你不要轻易把它设置为false。
[其他解释]
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TableTableAdapter tta = new TableTableAdapter();
Repeater1.DataSource = tta.GetData();
Repeater1.DataBind();
}
}