注册事件中的问题以进行验证 [英] Problem in Register event for validation

查看:51
本文介绍了注册事件中的问题以进行验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生们,我使用了以下代码:

Gentlemen, I have used the code:

Dim options As System.Web.UI.PostBackOptions = New PostBackOptions(Me, String.Empty)
Me.TextBox1.Attributes.Add("onchange", Page.ClientScript.GetPostBackEventReference(options, True))



在userControl的Load事件处理程序中.
该代码在某些项目中有效.
在另一个例子中,它给了我一个例外:

RegisterForEventValidation can only be called during Render();

问候;



in the Load event handler of a userControl.
this code worked in some project.
in another one it gave me the exception:

RegisterForEventValidation can only be called during Render();

Regards;

推荐答案

先生们,我很抱歉;

在第一个项目中,我在Web.config中禁用页面级别的事件验证:
Gentlemen, I apologize;

In the first project I was disabling event validation on the page level in Web.config:
<pages enableEventValidation="false">
...
</pages>



因此,我控制的正确代码是:



so, the correct code for my control is:

Dim options As System.Web.UI.PostBackOptions = New PostBackOptions(Me, String.Empty)
Me.TextBox1.Attributes.Add("onchange", Page.ClientScript.GetPostBackEventReference(options, False))



问候;



Regards;


这篇关于注册事件中的问题以进行验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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