在可编辑GridView多合一代码上使用DoubleClick事件的Pageback错误 [英] Pageback Error using Double Click event on Editable GridView All-in-one code

查看:107
本文介绍了在可编辑GridView多合一代码上使用DoubleClick事件的Pageback错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以Editable GridView All-in-one代码作为起点,它的工作原理很吸引人.我实际上已经对其进行了修改,以允许双击行事件和其他视觉美学.但是,我不确定为什么在该行上执行DoubleClick时会收到回发错误.如果将EnableEventValidation设置为False,该错误就会消失.由于这使我们可以进行可能的注入攻击,因此我想将其保留为True.
我添加了以下列,并以编程方式将可见设置为False.

I used the Editable GridView All-in-one code as a starting point and it is working like a charm. I have actually modified it to allow for double click row event and other visual asthetics. However, I am not sure why I am receiving a Postback error when I perform the DoubleClick on the row. If I set EnableEventValidation to False, the error goes away. Since this opens us up to possible injection attacks, I want to leave it as True.
I added the following column and programmatically set visible to False.

<asp:buttonfield text="DoubleClick" commandname="DoubleClick" xmlns:asp="#unknown" />



我将以下代码添加到GridView1_RowDataBound事件处理程序的底部:



I added the following code to the bottom of GridView1_RowDataBound event handler:

// Get the LinkButton control in the second cell
LinkButton _doubleClickButton = (LinkButton)e.Row.Cells[1].Controls[0];
// Get the javascript which is assigned to this LinkButton
string _jsDouble = 
ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "");
// Add this javascript to the ondblclick Attribute of the row
e.Row.Attributes["ondblclick"] = _jsDouble;
_doubleClickButton.Visible = false;



然后,我添加了以下Render事件:



Then I added the following Render event:

protected override void Render(HtmlTextWriter writer)
{
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
// validate the controls event
Page.ClientScript.RegisterForEventValidation(row.UniqueID + "$ctl0");
}
}
base.Render(writer);
}



我一直在网上检查帖子数小时并尝试各种示例,但似乎无法弄清楚为什么收到以下错误消息:
无效的回发或回调参数.使用< pages enableEventValidation ="true"/>启用事件验证.在配置中或<%@页面EnableEventValidation ="true"%>在页面中.为了安全起见,此功能验证回发或回调事件的参数源自最初呈现它们的服务器控件.如果数据有效且预期,请使用ClientScriptManager.RegisterForEventValidation方法以注册回发或回调数据以进行验证.
如果有人可以帮助,那就太好了!我不是新手程序员,但我是ASP.Net的新手.任何帮助将不胜感激.
克里斯汀



I have been online checking posts for hours and trying various examples but I can''t seem to figure out why I receive the following error message:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
If anyone could help, that would be great! I am not a novice programmer but I am a newbie to ASP.Net. Any help would be appreciated.
Kristin

推荐答案

ctl0); } } base.Render(writer); }
ctl0"); } } base.Render(writer); }



我一直在网上检查帖子数小时并尝试各种示例,但似乎无法弄清楚为什么收到以下错误消息:
无效的回发或回调参数.使用< pages enableEventValidation ="true"/>启用事件验证.在配置中或<%@页面EnableEventValidation ="true"%>在页面中.为了安全起见,此功能验证回发或回调事件的参数源自最初呈现它们的服务器控件.如果数据有效且预期,请使用ClientScriptManager.RegisterForEventValidation方法以注册回发或回调数据以进行验证.
如果有人可以帮助,那就太好了!我不是新手程序员,但我是ASP.Net的新手.任何帮助将不胜感激.
Kristin



I have been online checking posts for hours and trying various examples but I can''t seem to figure out why I receive the following error message:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
If anyone could help, that would be great! I am not a novice programmer but I am a newbie to ASP.Net. Any help would be appreciated.
Kristin


EnablePageValidation = true,此属性表示从浏览器向服务器提交表单时,应接受来自浏览器的html标签.
EnablePageValidation=true, this property means when submitting a form from browser to server,it should accept the html tags from the browser.


这篇关于在可编辑GridView多合一代码上使用DoubleClick事件的Pageback错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆